Pillars of Object Orientation
5 minutes
principles
Beginner
Modularity
Degree to which system is capable of being assembled and disassembled with multiple parts at reasonable cost
Examples
- Laptop is more modular than cup as harddrive can be replaced which handle of cup is not replaceable.
- Modular software has many components which are independent and replaceable.
Abstraction
It is act of finding common essential properties among set of objects and also, differentiating that set from other sets.
Examples
- Classifcation of anything e.g. taxonomy in biology
- Defining classes or common set of objects in OO languages
Encapsulation
Limiting access to private implementation only by public interface
Examples
- In a restaurant, customer has limited access to kitchen via waiter.
- In OO language, data members in class are kept private with public getters/setters as per context
Polymorphism
Limiting access to multiple different private implementations by single public interface
Examples
- If you learn to drive one car, you learn to drive almost all other cars.
- In OO language, same interface is implemented by multiple classes.
Hierarchy
Reverse tree like stucture
Examples
- Inheritance tree of classes in OO language
- 'Part of' relationship among parts of composite object