Home >Backend Development >PHP Tutorial >An in-depth analysis of the structural pattern of PHP design patterns_PHP tutorial

An in-depth analysis of the structural pattern of PHP design patterns_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 15:07:07882browse

There are many similarities between structural patterns because there are several relationships in the object model structure: inheritance and implementation between classes, plus object composition, which are the main purposes of PHP design patterns.

The biggest advantage of object composition is that a relationship can be established based on configuration at runtime without modifying the actual code. It is an operation required for class inheritance and interface implementation. In fact, you can define the functionality of an application by modifying the links between objects rather than between classes, which is part of the design.
List of structural patterns

 Adapter-Bridge-Facade

The goal of these three modes is competitive coupling:
◆Adapter mode (Adapter) uses different interfaces to connect objects;
◆Bridge mode (Bridge) Separate an M abstraction layer and an N implementation layer into N+M classes instead of M*N usage;
◆Facade creates a new unified interface to access subsystems.

 Composite-Decorator-Proxy

These three patterns maintain the same object interface, and they add orthogonal concerns transparently, without the client noticing:
◆The Composite pattern adds a container organization hierarchy for other objects, and the tree as a leaf of other trees Reuse;
◆ Decoration mode authorizes adding behaviors through interception methods to avoid introducing a large number of subclasses;
◆ Proxy mode authorizes operations for an object that does not yet exist or is difficult to access.

Finally, Flyweight is a standard implementation of ValueObjects without identity.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327558.htmlTechArticleThere are many similarities between structural patterns because there are several relationships in the object model structure: Between classes Inheritance and implementation, plus object composition, these are the main purposes of PHP design patterns...
Statement:
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