The solid principle of "turn" object-oriented design

Source: Internet
Author: User

S.O.L.I.D is the acronym for several important coding principles (programming Priciple) in object-oriented design and programming (Ood&oop).

SRP the single Responsibility principle  single responsibility principle
OCP the Open Closed principle 
LSP The Liskov Substitution Principle Richter substitution principle
DIP the Dependency inversion Principle dependency inversion principle
ISP the Interface segregation Principle interface separation principle

Steve Smith has a solidify Your ASP at Microsoft TechEd 2009 in May, Derick.bailey's solid development principles–in Motivationa L Pictures A good explanation of the solid principle.

Single Responsibility Principle:
There is only one reason when a class needs to be modified (there should never is more THAN A-REASON for a class-to-change). In other words, to have a class take only one type of responsibility, this class needs to be decomposed when the class takes on other types of responsibility.


Open Closure Principle
Software entities should be extensible and non-modifiable. In other words, the extension is open, and the modification is closed. This principle is one of the most abstract and difficult to understand in many object-oriented programming principles.

The principle of the Richter replacement
When an instance of a subclass should be able to replace any instance of its superclass, there is a is-a relationship between them

Dependency Inversion principle
1. High-level modules should not be dependent on low-layer modules, both should be dependent on abstract
2. Abstractions should not be dependent on detail, and details should be dependent on abstraction


Interface Separation Principle
You cannot force users to rely on interfaces that they do not use. In other words, using multiple specialized interfaces is better than using a single total interface.

These principles are very basic and important object-oriented design principles. It is because of the fundamental nature of these principles that understanding and integrating these principles requires a lot of experience and knowledge. The above picture is a good commentary on these principles.

The solid principle of "turn" object-oriented design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.