🐷
Practical Guide to Apply OOP Principles
Object-oriented programing
- Useful for:
- high maintananciblity
- Role devision
Explanation | Example | |
---|---|---|
encapsulation | Restrict external access to protect internal data | access modifiers |
abstruction | Extract significant features and encapsulate the details | abstract class, interface |
inheritance | Inherit features from base class | base class, sub class |
polymorphism | Integrate interface between among classes | Override methods, Overload methods |
SOLID Principle
Name | Explanation | |
---|---|---|
S | Single Responsibility | a class should have sole responsibility |
O | Open Closed | open to extend, close to modify |
L | Liskov Substitution | Sub class should be compatible with its Base class |
I | Interface Segregation Principle | Many client-specific interfaces are better than one general-purpose interface |
D | Dependency Inversion | High-level modules should not import anything from low-level modules |
How to apply
Phase | Principle |
---|---|
Requirements Definition | Single Responsibility |
Design | Intrface Segregation |
Coding | Liscov Substitution, Dependency Inversion |
Enhance | Open Closed |
Discussion