Programming in this language is all about manipulating objects: determining their properties, figuring out how they should behave, etc. The way to establish the characteristics of a certain object is to create for them a class which serves as the blueprint of their production. This is a powerful way to code since it allows us to be able to create Python objects which can model the objects of the real world. For example, in Exercise 1, we created a Dog object which was equipped with a name and the ability to play with a toy much like a dog in real life.
It gets even more interesting when different objects interact with each other. In the previous example, the toy the dog plays with is a separate object that follows it's own class' blueprint. In the same way that a real toy would behave, the dog object interacts with it to bring out its behaviour.
Another ability a programmer has in OOP is to create a subclass based on another class. For example, there may be a class Food with food objects and from that a subclass, Fruit, inherits the attributes of Food with its own unique specifications. This is not unlike how we organize and classify objects in life.
Object oriented programming brings out a connection between the real world and the virtual one.
I agree with your statement: OOP connects with the real world. But have you ever worked with a procedural language before?
ReplyDeleteChristina
http://comp-sci-christie.blogspot.ca/
Nope, it's only been Python so far :)
Delete