Dependency inversion principle Dip (dependency-inversion Principles)

Source: Internet
Author: User
Dependency-inversion principle
A. High-level modules should not depend on low-level modules. Both of them should depend on abstraction.
B. abstraction should not depend on details, but on abstraction.

The high-level module containsProgramImportant policy selection and business model in. it is these high-level modules that make all their applications different from others. if the upper layer depends on the lower layer, the changes to the lower layer modules will directly affect the upper layer modules, forcing them to make changes in turn.

Similar to OCP principles.
Each high-level layer declares an abstract interface for the required service. at a lower level, these abstract interfaces are implemented. Each high-level class uses the next layer of services through this abstract interface, the lower layer must implement high-level interfaces. Therefore, the lower layer is dependent on the higher layer.
Dependency inversion and interface ownership inversion.
Dependent on abstraction.
Heuristic rules:
1. No variable should hold a pointer or reference pointing to a specific class.
2. No class should be derived from a specific class (beginning with abstraction and coming from a specific class)
3. No method should overwrite the implemented methods in any of its base classes.

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.