The face of the object of Love Five Principles analysis!

Source: Internet
Author: User

Object-oriented programming in fact, we are explaining the concept of marriage

Object-Oriented Programming 5 principles, want to be the same as the object is the same:

Single responsibility Principle (SRP): To be a simple person, there will be simply "stable happiness-Eason Chan";
A class should have only one reason to cause it to change

Open closure principle (OCP): Understanding the past is not advice, know that the coming can still chase;
Open and closed, open to extensions, and closed to changes!

The Richter Replacement principle (LSP): The big radish can always be invincible;
Subclasses can replace the parent class and appear anywhere the parent class can appear, interface-oriented programming GOF

Dependency inversion principle (DIP): Love the economy must also be independent AH;
In traditional structured programming, the topmost modules are usually dependent on the following sub-modules, and
Called High-level dependency low! Dip to reverse this dependency, let the high-level module do not rely on the lower module
A. High-level modules should not be dependent on low levels of modules, they should all rely on abstraction.
B. Abstractions should not be dependent on specifics, but should be dependent on abstraction.

Interface isolation principle (ISP): Too much commitment brings only two people tired. Love don't make too many meaningless promises.
Using multiple dedicated interfaces is much better than using a single interface! The operation defined by the interface is equivalent to a commitment to the client, not too much commitment

The face of the object of Love Five Principles analysis!

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.