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. Summary of the 6 principles of design pattern
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 references to a base class must be able to transparently use objects of its subclasses. That is to say, any base class can appear...
2. 10 recommended articles about mvc design patterns
Introduction: 1. Code organization (directory structure) 2. MVC overview MVC design pattern is the MVC framework. The full name of MVC is Model View Controller, which is the abbreviation of Model-View-Controller. It is a software design model that uses a method to explicitly separate business logic and data to organize code and integrate business logic. Logic is aggregated into a component, so the interface and user interaction around the data can be improved and customized without having to rewrite the business logic. MVC was uniquely developed to reflect...
3. 5 recommended articles about openness and closure
Introduction: This article mainly introduces the open and closed principle of Java design pattern. The editor thinks it is quite good. Now I will share it with you and give it to everyone. Be a reference. Let’s follow the editor and take a look. I wrote it earlier. Recently, I took over a new business, and the system architecture is remarkable. But some places are intimidating, and some codes are bloated and difficult to maintain, which makes people unworthy. Therefore, based on the open and closed principle of Java, part of the code was refactored and optimized. Let’s first take a look at the old code of the previous system ShareChannelManager.javapublic&nb...
4. Recommended 10 articles about design
#Introduction: What is a custom function library? A function library is not a PHP syntax for defining functions, but a design pattern in programming. Functions are modules of structured programming and are the core of code reuse. In order to better organize the code, customized functions can be used in multiple files in the same project. Multiple customized functions are usually organized into the same file or multiple files. These files that collect function definitions are used to create PHP function libraries. If you want to use the functions defined in these files in a PHP script, you need to use include(), include_once(...
5. Details about custom function libraries introduce
Introduction: What is a custom function library? A function library is not a PHP syntax for defining functions, but a design pattern in programming. Functions are modules of structured programming and are the core of code reuse. In order to better organize the code, customized functions can be used in multiple files in the same project. Multiple customized functions are usually organized into the same file or multiple files. These files that collect function definitions are used to create PHP function libraries. If you want to use the functions defined in these files in a PHP script, you need to use include(), include_once(...
6. Recommend a few examples of introductory tutorials Introduction
Introduction: jquery is a fast and concise JavaScript framework that encapsulates commonly used functional codes in JavaScript , provides a simple JavaScript design pattern that can help us optimize HTML document operations, event processing, animation design and AJAX interaction in our daily development. It only requires a small amount of code to integrate them into the website. on the website, and can help visitors share the content on the website, which greatly improves our development efficiency. So today we will introduce to you several jquery introductory tutorials, including jquer...
7 . jquery introductory tutorial: 5 recommended jquery classic introductory tutorials
Introduction: jquery is a A fast and concise JavaScript framework, it encapsulates common JavaScript function codes and provides a simple JavaScript design pattern. In our daily development, it can help us optimize HTML document operations, event processing, animation design and AJAX interaction. , only a small amount of code is needed to integrate them into the website, and can help visitors share the content on the website, which greatly improves our development efficiency. So today we will introduce you to several jquery introductory tutorials, including jquery introductory videos. Tutorials, online manuals and jquery code and other related tutorials
8. Summary of common socket errors
Introduction: Socket is an intermediate software abstraction layer for communication between the application layer and the TCP/IP protocol family. It is a set of interfaces. In the design pattern, Socket is actually a facade pattern. , it hides the complex TCP/IP protocol suite behind the Socket interface. For users, a set of simple interfaces is all, allowing Socket to organize data to comply with the specified protocol
. 9. How to create a simple chat room using php websocket
Introduction: socket is The intermediate software abstraction layer that communicates between the application layer and the TCP/IP protocol family is a set of interfaces. In the design model, Socket is actually a facade model, which hides the complex TCP/IP protocol family behind the Socket interface, making it invisible to users. For example, a set of simple interfaces is all that is needed, allowing Socket to organize data to conform to the specified protocol.
10. PHP Advanced Object-Oriented Design Patterns: Observer Pattern Usage Examples
Introduction: What is the Observer Pattern? The Observer design pattern makes it easier to create objects that view the state of target objects and provides specific functionality that is uncoupled from core objects. The pattern is very simple: an object makes itself observable by adding a method that allows another object, the observer, to register itself. When an observable object changes, it sends messages to registered observers. These observers use this information to perform operations independent of the observable object. The result is that objects can talk to each other without having to understand why.
[Related Q&A Recommendations]:
Please give me some popular science about the MVC design pattern of swift
Does Python have design patterns?
php - Which framework’s source code is suitable for reading and learning?
javascript - How to combine react with some design patterns of js
The above is the detailed content of Summary of design pattern usage. For more information, please follow other related articles on the PHP Chinese website!