This week we have mainly learned Recursion,
which is basically use the same function to continue doing some work until the
end. This week the prof also introduced the function called turtle which is
really fun, seeing and understand the process how it actually worked and
processed. However, it was a little bit hard when it was the first time to
understand a recursion which was totally a new thing to me. However, Recursion
is really important in CS programming and in the first assignment, I plan to
look through it in more detail and try to do more practices on it and get used
to use Recursion and import it into my programming works. During the lab this
week, the unittest is still a problem which I had no idea how to do it.
However, the page of python was pretty helpful and provided me a lot of
suggestions to do it. The TA was patient as well, helping us through several
times to help us to understand it. There are a lot of assignments going on and
also the tests, so I did not have a chance to start it yet, but I will try to
work on it sometime during the weekend.
Friday, January 31, 2014
Tuesday, January 21, 2014
Object-orientated programming
OOP
All kinds of programming languages
including Java, C++, C, and python, which we are currently studying are all
object-oriented programming languages. Almost all the languages that are
popular now are OOP, which has a great advantage based on the way how it
organize the models of the objects. Basically, OOP is organized by encapsulation,
inheritance, and polymorphism.
Since OOP is ‘object-orientated’, it can
break the abstract and complicated parts into smaller pieces of objects to
break down issues.
We have not really learned about ‘encapsulation’
and ‘polymorphism’ yet, but basically, if my interpretation is right,
‘encapsulation’ is more like a box that prevent the access of codes and data by
the other data. This property helps to share the codes both publicly and
privately, which means showing people
codes that the programmer want them to see and hiding the private ones from
people to prevent them from modifying them. Apart from that, ‘polymorphism’ refers
to using the same name of the object while doing different things. We have not
learned this yet and I am not sure about this part, maybe my interpretation is
wrong, but it is my guess.
For ‘inheritance’, we just learned it
yesterday, which is to make subclasses of the basic classes. Based on the
example in class, the subset of exceptions have special-exception and
extreme-exception, which is the subset of class special-exception. That is to
say, exception has all the properties extreme-exception and special-exception
has. Thus, exception can basically include everything, yet special-exceptions
might only contain the strings, and extreme-exception only contains ints in
strings. In other words, each subclasses of classes has their own unique properties,
and the basic properties from the original class was inherited to all the
subclasses.
In conclusion, we have only touched the
basic stuff of OOP now, which means that we will be able to have more ideas
about ‘encapsulation’ and ‘polymorphism’ in the future. The comprehension of
inheritance might not be appropriate as well, but we are learning it now, so
more examples in classes and exercises might help us more on interpreting it.
Subscribe to:
Posts (Atom)