Object-oriented basics:
OO Basics |
Understanding |
Implementation Method |
Encapsulation |
Encapsulate objective things into abstract classes, and classes can only allow trusted classes or object operations for their own data and methods to hide untrusted information. |
|
Inheritance |
You can use all the functions of an existing class and extend these functions without re-writing the original class. |
Inheritance concepts can be implemented in three ways: Implementation inheritance, interface inheritance, and visual inheritance. |
Polymorphism |
The technology that sets a parent object to be equal to one or more other sub-objects. After a value is assigned, the parent object can operate in different ways based on the features assigned to its sub-objects. |
There are two methods to achieve polymorphism: overwrite and reload. |
Object-oriented principle:
OO principles |
Understanding |
Single Responsibility Principle |
For a class, there should be only one reason for its change. |
Open-closed Principle |
Class should be open to the extension and closed with multiple modifications |
Liskov replacement principle |
Subclass should be able to replace the parent class and appear anywhere the parent class can appear. |
Dependency inversion principle |
|
Interface isolation principle |
Using multiple interfaces related to a specific customer class is better than using a common interface that covers multiple business methods. |