Saturday, 7 February 2015
CSC148 blog2
In the first few week, CSC148 covers many knowledge, such as the recap of class, and special methods in the class, and brief introduction of abstract data type. Importantly, inheritance is completely new to me and it is one of the most significant topic in CSC148. To begin with, inheritance separates two kind of classes, parent class and children class. To be more precisely, parent class is the supper class that including general methods, such as init, str, eq. However, some specific methods cannot be written in the parent class because it is going to be different cases diver circumstance. For example, employ can be divided into hourly employe and salaried employe. Therefore, they are going to be paid differently and methods needs to be written in specific child class. Moreover, exception is mentioned in inheritance. Firstly, exception is used to ignore some errors because it is no need to care about them but programmer still wants the code works. For example, there could be a amount of pay in the employe parent class, but it cannot be written so far due to lack of information on how employe is paid. Therefore, programmer just need to write 'Not ImplementError' under the methods, and the code will run it without errors and programmer can add more information in the children class. In conclusion, inheritance is a very important skill for designing class.
Labels:
CSC148
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment