"Big Talk design mode": Dependence reversal principle

Source: Internet
Author: User

Dependency reversal principle

1, high-level modules should not rely on low-layer modules, two should be dependent on abstraction.

2, abstraction should not depend on detail, and detail should be dependent on abstraction. Programming for interfaces should not be programmed for implementation.

Principle of substitution on the Richter scale

If a software entity is using a parent class, it must be applied to its subclasses, and the difference between the parent and subclass objects is not perceptible. In other words, in the software, the parent is replaced by its subclass, and the behavior of the program does not change.

Subtypes must be able to replace their parent type.

The parent class can be reused only if the subclass is able to replace the parent class, and the child class can also add new behavior based on the parent class, if the functionality of the Software Unit is not affected.

Because of the substitution of subtypes, the modules of the parent type can be extended without changes.

Dependency reversal can be said to be the object-oriented design of the logo, in which language to write the program is not important, if the writing is to consider how to focus on abstract programming rather than the details of programming, that is, all the dependencies in the program are terminated in the abstract class or interface, that is, object-oriented design, which is the process of design.

"Big Talk design mode": Dependence reversal principle

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.