Home >Backend Development >PHP Tutorial >PHP Design Patterns: Structural Patterns_PHP Tutorial
BKJIA Exclusive Feature] In " PHP Design Pattern Talk " we learned that there are many similarities between structural patterns, because in the object model structure There are several relationships: inheritance and implementation between classes, plus object composition, which are the main purposes of PHP design patterns.
For more information on "PHP Design Patterns", you can refer to BKJIA's previous reports: PHP Design Patterns: Chain of Responsibility Model DRAWINGS ON PHP DESIGN PATTERNS: AGENCY MODE
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) separates an M abstraction layer and an N implementation layer into N+ M class, instead of M*N usage;
◆Appearance mode Facade) creates a new unified interface to access subsystems.
Composite-Decorator-Proxy)
These three patterns maintain the same object interface, they add orthogonal concerns transparently, and the client will not be aware of it:
◆The composite pattern adds a container organization hierarchy for other objects, and trees as leaves of other trees Reuse;
◆ Decoration mode adds behaviors through interception method authorization 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.
Original title: Practical Php Patterns: Structural patterns summary Author: Giorgio
Original source: http://giorgiosironi.blogspot.com/2010/02/practical-php-patterns-structural.html