Home >Backend Development >PHP Tutorial >Overview of PHP object-oriented design principles
Object-orientedDesign principles were born to support maintainability and reuse. These principles are contained in many design patterns, They are guiding principles summarized from many design solutions. Understanding Object-oriented design principles helps us understand design patterns. Design descriptions are all derived from Object-oriented design principles
Object-oriented design principle of single responsibility principle
Answer: A class is only responsible for the corresponding responsibilities in one functional area, or it can Definition: For a class, there should be only one reason for its change
Object-oriented design principles of opening and closing principles
Answer: A software entity such as a class , modules and functions should be open for extension and closed for modification. That is, the software entity should try to be extended without modifying the original code.
Object-oriented design principles: Liskov substitution principle
Answer: All places that reference a base class (parent class) must be able to transparently use objects of its subclasses .
Object-oriented design principle Dependency Inversion Principle
Answer: Abstraction should not depend on details, details should depend on abstraction. In other words, program to the interface, not to the implementation.
Object-oriented design principles of interface isolation principle
Answer: Use multiple specialized interfaces instead of a single general interface, that is, the client should not rely on those It doesn't require an interface.
Object-oriented design principles of composition and reuse
Answer: Try to use object combination instead of inheritance to achieve the purpose of reuse
Object-oriented design principles: Dimit's Law
Answer: A software entity should interact with other entities as little as possible
Related recommendations :
PHP object-oriented design and data accessible design
##About object-oriented PHP - the definition of classes, the instantiation operations of objects, and the special usage of constructors and destructors - WORSHIP Yasa
The above is the detailed content of Overview of PHP object-oriented design principles. For more information, please follow other related articles on the PHP Chinese website!