Week 3
Why geeks should write?
Communication is a
fundamental pillar of knowledge that involves using oral, gestural and
written skills. However, writing seems to be the most common way of
transmitting information in academia. Books, papers, journals and articles are
just some of the ways in which academic knowledge is diffused. When talking
specifically about Computer Science and coding, documentation strings and
comments appear as clear examples of the use of writing.
Working in groups is
very common in Computer Science. Students are always encouraged to share ideas
and to work together to find a solution. Such collaboration can only be
achieved by a proper transmission of ideas which often involve good
documentation and commenting. The same is true for computer scientists who by
communicating their ideas among peers are able to broaden their view and to
obtain better results.
The development of
new knowledge is based upon the use of earlier pieces of work. In the case of
computer science, efficient code is achieved by looking at other people´s code
and finding more efficient algorithms and shortcuts. The improvement of
existing knowledge, code, lies on the ability of the writer to follow a clear
style accessible to others. Therefore, being able to write properly is important
because it allows other people to understand our work.
Communication of
findings through academic resources such as journals and articles also relies
on the authors’ writing skills. Peer-review process is needed for ideas to be
published and the best and only way to go through this process is by
facilitating the reader’s understanding of the code. As Joel Spolsky
mentions in his article “Advice for Computer Science College Students”, writing
is a powerful mean that can make developers stand out among their peers. Writing
properly allows people to better communicate ideas. The more clear the writing,
the stronger the arguments people make and the easier will be to inform other
people’s behaviour.
In a nutshell,
communication, which is mainly achieved by writing, plays an important role in
the transmission of ideas. Appropriate documentation and good commenting give
rise to a better understanding of the code, which translates into proper
communication and improvement of knowledge. Moreover, having good writing
skills bring about convincing communication; which opens the doors for
opportunities.
Reaction to the course
During these weeks we
have discussed the __str__ and __repr__ methods, as well as testing.
Methods and its use
I was a little bit
confused about the difference between the __str__ and __repr__ methods, but a
careful look at the docstrings of these methods and the output generated by the
program point.py made me understand how they work.
·
__str__
Return a string version of self
The method __str__
gives us some useful information about the class in which we are working on.
Example:
(4.0, 5.0) the
coordinates of a point
·
__repr__
Return a string representation of self
The method __repr__
allows us to create a comprehensive way of creating an instance of a class. Example:
Point(4.0, 5.0)
Testing
At the beginning I
did not know the reason for having two different types of tests, but it seems to
me that now I understand the differences between doctest and unittest.
Doctest
Doctest is a type of
test that runs within the same program that it checks and depends upon the
docstring written by the programmer. It is useful when trying to find small
errors within our code. However, doctest does not allow us to check for every
single possible case that could fail because that would make our docstings
really long, and therefore, our code hard to read.
Implementation
if __name__ == ’__main__’:
import doctest
doctest.testmod()
Unittest
Unittest is a type of
test that is written in a separate file. Importing the unittest module and the
program to be tested is necessary. This test comes into place in situations in
which we want to check for every single case.
Implementation
import unittest
import programtobetested
class ProgramTestCase(unittest.TestCase):
def testcase_example1:
if __name__ == ’__main__’:
unittest.main(exit=False)
Course Interaction:
Some of the discussion I took part in are:
Course Interaction:
Some of the discussion I took part in are:
No comments:
Post a Comment