Dependency inversion Principle (dependency inversion principle)

Source: Internet
Author: User

This article by @ To stay for the original, reproduced please indicate the source.

Dependency inversion Principle (dependency inversion principle, hereafter referred to as DIP): Do not rely on instances (concrete classes) programming, dependency abstraction (abstractions, refers to dependent abstract classes and interfaces).

understanding of inversion (inversion): usually our high-level components are dependent on the lower component (referred to as a lower-specific instance Class), and dip is not allowed, under the guidance of the dip, we will create an abstract class, so that it is between the high-level components and the lower components, To break this dependency, not only is the high-level component dependent on this abstract class, but the lower component will depend on the abstract class where it is located higher than its upper level, so there will be an "upside down" argument.

Several guidelines for this principle (not necessarily to be sure, just as a reference at the time of development)

1, do not have an application that points to a specific instance (concrete Class) (there is no new in Java).

2, do not have classes derived from specific instances (concrete class).

3, do not overwrite methods already implemented in the parent class.

Dependency inversion Principle (dependency inversion 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.