Chapter 4 computer repair without radio repair-dependency reversal Principle

Source: Internet
Author: User
Abstraction should not depend on details. Details should depend on abstraction. For interface programming, do not implement programming. 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. Details should depend on abstraction.Why is it reversed? Process-oriented development is to make the code reusable. These common codes are generally written into libraries of many functions. In this way, we are working on a new project, you can call these underlying functions. For example, most of our projects need to access the database, so we write the code for accessing the database as a function. Every time we create a new project, we call these functions, this means that the high-level module depends on the underlying module. Rys replacement principleChild types must be able to replace their parent types. If a software entity uses a parent class, it must be applicable to its subclass and cannot detect the difference between the parent class object and the Child class object. That is to say, in the software, replace the parent class with its Child class, and the behavior of the program remains unchanged. Only child classes can replace the parent class. the functionality of the software unit is unaffected, so that the parent class can be reused. Child classes can also add new behaviors based on the parent class. Because the child type can be replaced, the module that uses the parent class can be expanded without modification. Dependency inversion can be said to be a sign of object-oriented design. It is not important to write a program in which language. Abstract ProgrammingInstead of detailed programming, that is, all dependencies in a program are terminated by abstract classes or interfaces, that is, object-oriented design, and vice versa, procedural design.

Chapter 4 computer repair without radio repair-dependency reversal Principle

Related Article

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.