2015年2月15日星期日

Summary of object oriented programming concept (week #6)

Python is an object oriented language. It has class, class variable, data member, function overloading, instance variable, inheritance, instance, instantiation, method, object, operator overloading etc. Actually, what we learn in the course csc148 till now is almost all about the OOP.
Python's heart is object and OOP. In python, the basic elements are called object such as integers, strings and functions and so on. Now I want to focus on the class and inheritance. (That's because I think they are the basic two things in OOP.)
Firstly, classes define what is the common thing that the objects inside it has. We often find a general name for the class and classes correspond to variable types.
- class


 
Secondly, we subclass(extends) a superclass(base class) by *


1. declaring that we're extending it... *
class NewClass(OldClass):*
...
2. add methods and attributes to specialize*
3. other methods and attributes are searched for in superclass*
 (* are from Prof Heap's vanilla PPT)




2015年2月6日星期五

tracing recursion

Firstly, I find it hard to trace the recursion, especially when the example becomes complicated. We always start from the simplest example and skip similar steps to get more complicated cases.When I trace the queue list at lab04, I find it is helpful to write the down all the parameters in the codes because it helps me to understand it fully.
When I get lost at tracing the codes, I use the python visualizer to help to get the right answer. 
I always think that writing a recursion is much more difficult. In lab03 I find it hard to get the answer. What I do is assuming some codes first then verifying whether it is true. However, it is still hard to get the answer.