Home > Backend Development > PHP Tutorial > Summary of 6 principles of design patterns

Summary of 6 principles of design patterns

巴扎黑
Release: 2023-03-09 08:54:02
Original
1897 people have browsed it

Definition of the Single Responsibility Principle: Do not have more than one reason for a class change. In layman's terms, a class is only responsible for one responsibility. Liskov substitution principle definition 1: If for every object o1 of type T1, there is an object o2 of type T2, so that all programs P defined with T1 will have program P when all objects o1 are replaced with o2. There is no change in behavior, then type T2 is a subtype of type T1. Definition 2: All references to a base class must be able to transparently use objects of its subclasses. In other words, wherever a base class can appear, a subclass can definitely appear. In layman's terms, the Liskov substitution principle is: subclasses can extend the functions of the parent class, but they cannot change the original functions of the parent class. It contains the following four levels of meaning: 1). Subclasses can implement abstract methods of the parent class, but cannot override non-abstract methods of the parent class. 2). Subclasses can add their own unique methods. 3). When a method of a subclass overrides a method of a parent class, the preconditions of the method (that is, the formal parameters of the method) are looser than the input parameters of the parent class method. 4). When the method of the subclass implements the abstract method of the parent class, the postcondition of the method (that is, the return value of the method) is higher than

1. Detailed introduction to the design pattern Six Principles

Summary of 6 principles of design patterns

Introduction: Single Responsibility Principle Definition: Do not have more than one reason for a class change . In layman's terms, a class is only responsible for one responsibility. Liskov substitution principle definition 1: If for every object o1 of type T1, there is an object o2 of type T2, so that all programs P defined with T1 will have program P when all objects o1 are replaced with o2. There is no change in behavior, then type T2 is a subtype of type T1. Definition 2: All places that reference a base class must be able to use its subclasses transparently

2. PHP Design Patterns - Six Principles_PHP Tutorial

Summary of 6 principles of design patterns

Introduction: PHP design patterns - six principles. PHP Design Pattern - Six Principles It is generally believed that code that follows the following six principles is easy to expand and reusable: These six principles should be followed by any object-oriented language. To

3. PHP Design Pattern - Simple Factory_PHP Tutorial

Summary of 6 principles of design patterns

Introduction : PHP design pattern - simple factory. PHP Design Pattern - Simple Factory The first two sections introduce what design patterns are and the six principles. I believe that after reading the first two sections, everyone has a preliminary understanding of design patterns. Continue

4. PHP Design Pattern--Six Principles

Introduction: PHP Design Pattern--Six Principles

5. Six Principles of PHP Design Pattern (5): Dependency Inversion Principle

Introduction: Six Principles of PHP Design Pattern (5): Dependency Inversion Principle

6. Six Principles of PHP Design Pattern (6): Demeter’s Law

Introduction: Six Principles of PHP Design Patterns (6): Demeter's Law

7. Six Principles of PHP Design Patterns

Introduction: PHP design patterns-six principles. PHP Design Pattern - Six Principles It is generally believed that code that follows the following six principles is easy to expand and reusable: These six principles should be followed by any object-oriented language. To

8. PHP Design Pattern Simple Factory

Introduction: PHP Design Pattern-Simple Factory. PHP Design Pattern - Simple Factory The first two sections introduce what design patterns are and the six principles. I believe that after reading the first two sections, everyone has a preliminary understanding of design patterns. Continue

9. Learning Design Patterns Proxy Pattern

Introduction: When I was studying the decoration mode randomly, I gave a reference article that compared the decoration mode and the proxy mode. Naturally, this is what OneCoder now needs to understand. First review the six principles of design patterns: Six principles of design patterns (quoted from: http://zz563143188.iteye.com/blog/1847029) 1. Open Close Principle

10. Six Principles of Design Patterns (2): Richter Substitution Principle

Introduction: There must be many people like me who just saw this As before, the name of this principle is full of confusion. In fact, the reason is that this principle was first proposed by a woman named Li (Barbara Liskov) from MIT. Definition 1: If. For every object o1 of type T1, there is an object o2 of type T2, so that T1 determines

[Related Q&A recommendations]:

The above is the detailed content of Summary of 6 principles of design patterns. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template