Home > Backend Development > PHP Tutorial > Detailed explanation of PHP design pattern category examples

Detailed explanation of PHP design pattern category examples

小云云
Release: 2023-03-20 22:20:01
Original
1497 people have browsed it

MVC is a very important point in design pattern development, but this is just a starting point. There are already a lot of relevant documents describing the use, misuse, and abuse of MVC in programming. In general, design patterns are organized according to their functions and scopes. The functions of design patterns can be divided into three categories:
Creative type
Structural type
Behavioral type
This classification page reflects It achieves the goals that are generally achieved by man-made models.
Design patterns can be divided into two categories according to scope:
Class
Object
This blog post will briefly introduce these categories and explain the benefits of such a division for selecting and understanding design patterns.
Creative Pattern
As the name suggests, the creative pattern is a pattern used to create objects. Rather, these patterns are abstractions over the instantiation process. If a program relies increasingly on composition, it will rely less on hard-coded instantiations and more on a flexible set of behaviors that can be organized into a more complex collection. Creational patterns provide ways to encapsulate knowledge about specific classes used by the system and to hide information about instance creation and composition.
Structural Pattern
These patterns are concerned with the fact that the combined structure should be structured. Structural class patterns use inheritance to compose interfaces or implementations. The Structural Object Pattern describes how to combine objects to create new functionality. Understanding structural patterns is helpful in understanding and working with related classes.
Behavioral Pattern
So far, most patterns are behavioral objects. The core of these patterns is the distribution of responsibilities between algorithms and objects. These design patterns describe more than just patterns for objects or classes; they also describe patterns of communication between classes and objects.
Class pattern
Among the two types of scope, the first type of scope is the class. The focus of these class patterns is on the relationships between classes and their subclasses. There are four modes included in the class scope, and the class mode is static.
Object Pattern
Although most design patterns belong to the object scope, many patterns also use integration, as do those patterns in the class scope. The difference between the object design pattern and the class pattern is that the object pattern emphasizes objects that can be changed at runtime, so these writing patterns are more dynamic.
The difference between design patterns and frameworks
Compared with frameworks, design patterns are smaller elements in the architecture and are more abstract. Additionally, design patterns are less specific than frameworks. Therefore, design patterns are more reusable and flexible than frameworks.
Frames are somewhat similar to templates: they are more indicative and can more clearly indicate the structure of the problem being solved. In order to provide this ease of use, they have to give up the flexibility of the architecture. If you use a framework, building applications will be much faster, but the applications you build will be constrained by the framework itself. Frameworks can be semi-object-oriented structures, and often frameworks are layered, with each layer dealing with an aspect of the larger design. Some features of the framework are also reflected in the design pattern. However, the design pattern is not as specific and specific as the framework, nor is it as huge.

Related recommendations:

A brief introduction to PHP design patterns

Detailed explanation of service locator pattern examples of PHP design patterns

Detailed explanation of the memo pattern of PHP design pattern

The above is the detailed content of Detailed explanation of PHP design pattern category examples. 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