Wednesday, January 22, 2014

Week 3: Object-oriented Programming

Python's main focus is geared toward OOP, which--in a nutshell--allows people to create different objects and assign them attributes and methods.  Although we have much left to talk about in class, I can already see how OOP plays such an important role in computer science.  Not only will it allow programmers to create effective and efficient code to model real-world objects and trends, but its applications are immense: business, science, entertainment, healthcare--it surrounds us.

We've recently discussed how to create new classes, methods, and attributes, and even dabbled on inheritance.  Objects can be assigned unique traits and be made to perform specific actions (methods), which isn't all that different from their real-life counterparts.  Likewise, the concept of inheritance is similar to its counterpart, in which the parent class passes on its methods to child classes; a child class can override its inherited methods by substituting different code, and even create new methods of its own.  I'm a little bit sketchy as to how effective multiple inheritance is, because it seems to me that creating a new (non-child) class would be much less confusing, especially when the parent classes contain many unnecessary methods that would be passed down.  In class, the Stack and IntStack examples showed the basics of OOP (its components, creation) as well as in what circumstances inheritance would be useful (when two classes perform related tasks).  I'm currently having a little trouble understanding the __repr__ method, so I will probably read up and write some examples to catch up.

Having done Java in the past, OOP is pretty familiar to me.  What I find interesting, and would definitely like to learn more about, are the similarities and differences between Java and Python ways of object creation.  What are the strengths and weaknesses of each?  It seems like neither language should hold a greater advantage than the other considering that they both do the same thing (create objects), but then why would there be two languages?  I'm curious as to what others think of languages and OOP in general: do you think it's a difficult topic to understand at this time and is Python object-programming much different than what you've done in the past?

No comments:

Post a Comment