|
while you are correct that these items are important to programming, I will have to disagree in part. This is because you can have those characteristics in non OO languages. Inheritance is a great (and necessary) feature, and you wouldn't have proper polymorphism without it. Essentially what your textbook is trying to get across is that the reason OO programming was created, is to allow objects to share traits and inherit traits (methods), while still having each object handle each difference independently. A simple example would be a line such as: animal.speak(); animal is an object with subclasses, dog, cat, etc who knows, but something exists to give a more defined meaning, but we are able to generalize the speak command due to polymorphism. All animals can speak, but they all do it differently, thus allowing a general method call, perhaps running code like "open mouth" for all animal types, but the specific class still separates the actions.
|