Below is my revised version of week 6's impressions about Object Oriented Programming.
------------------------------------------------------------------------------------------------------------------
Object-oriented programming , as the name suggested, is a style of programming in which data and the operations are organized into objects. In other words, programmers focus on objects instead of the implementation details.
Here a few terms I had to define:
Object: A basic entity in Python that models a thing or concept in the real world, which contains attributes and behaviours.
In fact, every value in Python is an object, like str, int, list and dictionary.
Inheritance: A mechanism involves classes inherit (get) commonly used attributes and behaviours from other classes. A subclass (child) class, by default, inherits all the methods and attributes of the super (parent) class.
Class: A template or blueprint for the objects of similar types.
My thoughts of OOP can be thought of as better organization and removing redundant code.
Methods are special functions written for a related class. This removes the concept of having a multitude of functions that each refer to some object. Thus, methods in classes are simply used to group related manipulators of objects and associate them with a class.
Inheritance was an extremely defining term in my mind. It allows me to reuse the same methods for inherited objects without having to encounter the problem of duplicate code.
In the example below, the use of inheritance from object oriented programming exemplifies the removal of having to initialize address and room as in class Townhall by inheriting the attributes from class House.
In addition, OOP removes the concept of having multiple functions referring to different objects by organizing them into classes and sub classes so that methods have a direct correlation to their class and subclasses. Professor Heap gave us a great example in class that demonstrated this concept. First he showed a few functions that were related to class point. Then he introduced another class called Heavypoint which had some duplicated code with the the parent class point. In the end, the professor cut down the duplicated areas and reduced the messy python code into classes followed by there methods and subclasses.
In summary, object oriented programming make modification to pre-existing code easy due to the ability to inherit methods and attributes from a parent class.