An overview of PHP object-oriented design principles

Source: Internet
Author: User
Object-oriented design principlesBorn to support maintainability multiplexing, these principles are embedded in many design patterns, which are the guiding principles that are summarized in many design scenarios, and understand Object-oriented design principlesHelps us understand design patterns, and design instructions are all derived from Object-oriented design principles


Single responsibility principle of object-oriented design principle

A: A class is responsible only for the corresponding responsibilities in a functional area, or can be defined as: For a class, there should be only one cause for it to change

Open and close principle of object-oriented design principle

A: A software entity such as classes, modules, and functions should be open to extensions and closed for modification. That is, the software entity should try to extend without modifying the original code.

The principle of object-oriented design principle in the Richter scale substitution

A: All references to base classes (parent classes) must be able to transparently use objects of their subclasses.

Dependency reversal principle of object-oriented design principle

A: Abstractions should not be dependent on detail, and detail should be dependent on abstraction. In other words, you want to program for the interface, not for the implementation.

Interface isolation principle of object-oriented design principle

A: Use multiple specialized interfaces instead of a single total interface, that is, the client should not rely on interfaces that it does not need.

The principle of object-oriented design in synthetic multiplexing

A: Try to use object combinations rather than inheritance to achieve reuse

The principle of object-oriented design for the DISA rule

A: A software entity should interact with other entities as little as possible

Related recommendations:

Design of PHP object-oriented design and data accessibility

About PHP Object-oriented-class definition and instantiation of objects and special usage of construction and destructor-worship

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.