Design Pattern 5-computer repair without radio repair-dependency reversal pattern

Source: Internet
Author: User

Single responsibility: The computer has just been repaired. Obviously, the memory is broken and should not be the reason for CPU replacement. Their Respective responsibilities are clear;
Open-closed Principle: The memory is not enough, as long as the slot is enough to be added, the hard disk is not enough to use mobile hard disks, etc. The PC interface is limited, so the expansion is limited, and the software system is well designed, but it can be expanded infinitely.

Dependency reversal Principle
Abstraction should not depend on details. Details should depend on abstraction (for interface programming, not for implementation programming) for abstract programming rather than for detail Programming
Dependency reversal 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. Details should depend on abstraction.

LSP: child types must be able to replace their parent types (for example, when learning the concept of inheritance, child classes inherit the parent class, and child classes can appear as parent classes. Is-a principle)
If a software object uses a parent class, it must be applicable to its subclass and cannot detect the difference between the parent class object and the subclass object. That is to say, in the software, replace the parent class with its Child class, and the behavior of the program remains unchanged.

Dependency inversion can be said to be a sign of object-oriented design. It is not important to write a program in which language. If the programming is based on abstract programming rather than detailed programming, that is, all dependencies in the program end with abstract classes or excuses, that is, object-oriented design, and vice versa, that is, procedural 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.