Basically the OO technique describes a collection of cooperating objects. This is opposed by the older technique of writing an application as a group of sub-routines. Each object is capable of receiving messages, sending messages, and processing data. They should be viewed as independent machines with distinct roles and responsibilities.
The most basic form is the class. A class describes the abstract characteristics of an object (its properties and methods). Likewise, an object is an instance of a class (Lassie is an instance of the dog class).
Furthermore, there are three main pillars of thought which make up the OO paradigm: encapsulation, inheritance, and polymorphism.
- Encapsulation - Each object should define which members are publicly exposed to its clients. This concept is better described as an interface. The public interface should not need to know how the implementation is carried out, or when it changes. This interface should always remain static.
- Modularity - This concept defines the separation of the interface and the implementation. Described more basically, the application, should be built of interacting parts.
- Inheritance - Sub-classes should be able to inherit or derive from parent classes. They should also have the ability to add or modify members of the parent class. This also enables the developer to write significantly less code.
- Abstraction - further describes the concept of inheritance by modeling a complex problem set with a more simple collection of objects. A developer should be able to manipulate the appropriate level of inheritance for the given operation. For example, a driver only need to know how to turn the key to get the car started, they do not need to understand how the engine works, however, the mechanic may.
- Polymorphism - Defines the ability of the derived classes to modify the parent class. Polymorphism is accomplished through overriding or overloading members of the parent class.
No comments:
Post a Comment