An in depth analysis of structural patterns of PHP design patterns

  • 2020-06-15 07:52:56
  • OfStack

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

The greatest advantage of object composition is that it allows you to establish a relationship based on configuration at run time 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 links between objects rather than between classes, which is part 1 of the design.
List of structural patterns

Adapter - Bridge - Appearance (Adapter-ES8en-ES9en)

The goal of these three patterns is competitive coupling:
◆ The adapter pattern (Adapter) USES different interfaces to connect objects;
◆ Bridge mode (Bridge) separates one M abstract layer and one N implementation layer into N+M class, which replaces M*N usage.
◆ Appearance mode (Facade) creates a new interface to access the subsystem.

Composite - Decoration - Agent (Composite-ES27en-ES28en)

These three patterns maintain the same object interface and they transparently add orthogonal concerns without the client noticing:
◆ The composite pattern adds a container organization hierarchy to other objects and reuse trees as leaves of other trees;
◆ Decorator mode avoids the introduction of a large number of subclasses by intercepting method authorization behavior;
◆ The proxy mode authorizes an operation on an object that does not yet exist or is difficult to access.

Finally, Flyweight is a stateless ValueObjects standard implementation.


Related articles: