The Five Principles of Object Oriented Design SOLID

1. S Single Responsibility Principle

     Single Responsibility Principle (Single Responsibility Principle) Each method or class should only do one thing, or only one responsibility.

 

Two, O open closed principle

    The Open Closed Principle is at the heart of all object-oriented principles.
 

 

3. L Liskov Substitution Principle

    All the implemented methods in the parent class (relative to abstract methods) are actually setting a series of specifications and contracts, although it does not mandate that all subclasses must comply with these contracts, but if the subclasses are not aware of these non- Any modification of abstract methods will cause damage to the entire inheritance system.

  In the succession process there are the following terms:

   A. A subclass can implement the abstract methods of the parent class, but cannot override the non-abstract methods of the parent class

   B. Subclasses can add their own unique methods

   C. When the method of the subclass overloads the method of the parent class, the formal parameters are wider than the formal parameters of the parent class method.

   D. When the subclass method implements the abstract method of the parent class, the return parameters are more precise than the parent class

 
 4. I interface separation principle

   Users cannot be forced to rely on interfaces they do not use.

 

 5. D Dependency Inversion Principle

    1. High-level modules should not depend on low-level modules, both should depend on abstractions 

    2. Abstraction should not depend on details, details should depend on abstraction 


 

     

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326502373&siteId=291194637