Home >Backend Development >PHP Tutorial >PHP Design Patterns: Structural Patterns_PHP Tutorial

PHP Design Patterns: Structural Patterns_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:19:08755browse

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

  1. Responsibility Chain Model of PHP Design Patterns
  2. Proxy Pattern of PHP Design Patterns
  3. Ten tips for PHP developers to get twice the result with half the effort
  4. FirePHP: Debug your PHP code like Firebug
  5. How to correctly implement PHP to obtain blog data

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/587974.htmlTechArticle51CTO exclusive feature] In "Discussing PHP Design Patterns" we learned that there are many similarities between structural patterns place, because there are several relationships in the object model structure: inheritance between classes...
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