Friday, 24 January 2014

About OOP and Week 3 Reviews

Object-Oriented Programming is an important concept that we would keep learning though courses and practices. We learned how to find and design a class and its builtin functions in a paragraph of descriptions, and the special method property.

During this week, I learned the inheritance of class and raising exceptions. They both have several ways to achieve. These are difficult for me because of their abstract ideas and unfamiliar operations. However, after I read through the readings and finished the lab and exercise, I have better understating on the attributes of subclass and superclass. I learned how to call old class, and the “super” method. Therefore, the class is reusable and becomes more efficient. At the beginning, I got confused about the interactions between different classes such as their order of implement. Nevertheless, after I read "Inheritance vs. Composition", lots of examples made me understand its basic operations. More importantly, I learned the composition is much simpler than the inheritance and we would be better to choose the lower cost one, because "in Object-Oriented Programming, Inheritance is the evil forest."

Also, I had questions through my preview but later on I understand how it works though the lecture. When I creates two stack by same procedures, they are not equivalent, that is because I create two different objects, therefore, we need to write a "__eq__" method to assign their equivalence.

The exceptions occur in various situations and many ways of expression. We can simply use the existing exceptions such as "1/0", "int('two')". Moreover, we create a class to raise exceptions which contain more precise description of the error on latter stages. Last but not least, we learned a new method, "try" statement with "finally" clause, which I found is similar with "if" statements. The flexible usage of exceptions make itself concise and understandable.