Wednesday, January 22, 2014

Week3: Object oriented programming

So far, we have been learning object oriented programming for 3 weeks and it gives me a feeling that object oriented programming is revealing a much more colorful world of programming for all of us. And there are so many new stuffs to learn and to think about. We no longer depend on and learn from the weekly video lectures which have limited time and material in it, but are supposed to read more professional articles and discover those sometimes confusing but useful methods on the Internet on our own. This can be not only very challenging but frustrating as well, because every time I read those articles, I can't wholly understand them, and I feel like it's still a long way to go to become a professional and experienced programmer.

During the 3-week studying about OOP, I find two things quite interesting. One is that almost everything in Python is an object. For example, we can do many things with "list", because any list is an object from maybe "List Class", and those methods are defined inside this class. Therefore, every object has its own memory address. An interesting analogy about class is "Human Class". We are all different object of "Human" class. We have names, which are the attributes of the objects from this class, and we also have "methods" such as eating and drinking, which may result in the change of our weights and heights that are attributes of this class. The other interesting thing is that there is inheritance among classes. Every class inherits automatically from "object" class, which has many special methods in it such as "__init__", ""__eq__"". And we can also override those old methods without changing any code from the parent class. What's more, we can use the built-in function super() to call the methods in the parent class any time we like, which gives us much freedom. However, I think we lack practice about class inheritance and I hope we will encounter problems about it in the assignments.

No comments:

Post a Comment