PHP Design Patterns and coupling and polymorphism
What is design mode:
Design patterns are a template that teaches you how to organize your code with real and reliable design.
All design patterns have some common features: an identity (a name), a problem statement (a problem statement), and a solution (a solution).
1, a design pattern of the logo is important, because it will let other programmers without too deep learning to understand the purpose of your code immediately (at least through this logo programmer will be familiar with this mode).
2. The problem description is a field used to illustrate the application of this pattern.
3. The solution describes the execution of this model. The elaboration of a good design pattern should cover the advantages and disadvantages of using this model.
For example, a shirt you buy from a store is a code base whose color, style, and size are determined by the designer and manufacturer, but it meets your needs. However, if there is nothing in the shop that suits you, you can create your own shirt (design its shape, choose the fabric, and then tailor it together). But if you are not a tailor, you may find it easy to find a suitable pattern and then follow this pattern to design your own shirt. With a model, you can get a skilled design shirt in less time.
PHP has a total of 23 traditional design patterns,
Interpreter (interpreter mode), Factory (Factory mode), facade (appearance mode), Decorator (decoration mode), builder (Builders mode)
Adapter (adapter mode), template (stencil mode), command (chain mode), Singleton (singleton mode), OBSERVER (Observer mode)
Strategy (Policy mode), Visitor (visitor mode), Memento (Memo mode), Prototype (prototype mode), Mediator (Broker mode)
FlyWeight (enjoy meta mode), Chain of Responsibility (responsibility chain Mode), Bridge (bridge mode), Proxy (agent mode), State (status mode)
Composite (combined mode), Interator (iterator mode), DAO (data Access object mode), delegation (delegate mode)
There are five types of PHP common design patterns
1. Factory mode 2. Singleton mode (single element mode) 3. Observer Mode 4. Command chain mode 5. Policy mode
What is coupling:
Coupling (coupling), also known as coupling degree, is a measure of the degree of association between modules. The strength of the coupling depends on the complexity of the interface between modules, how the module is called, and how much data is transferred through the interface. The coupling degree between modules refers to the dependencies between modules, including control relationships, call relationships, and data transfer relationships. The more connections between modules, the stronger the coupling, and the lower the independence of the module. In software design, coupling degree and cohesion are usually used as the standard to measure the independence degree of the module. One of the criteria for dividing a block is cohesion-poly-low coupling
What is polymorphism:
"For object-oriented programming languages, Polymorphism is the third most basic feature (the first two are data abstraction and inheritance.) ”
"Polymorphism" (polymorphism) separates interfaces from specific implementation details from another perspective, i.e. the separation of "what" and "how to Do" two modules. Using the concept of polymorphism, the organization of code and readability can be improved. In addition, you can create "easy-to-extend" programs. They can be easily "grown" both during the creation of the project and when new features need to be added.
http://www.bkjia.com/PHPjc/997425.html www.bkjia.com true http://www.bkjia.com/PHPjc/997425.html techarticle PHP Design Patterns and coupling and polymorphism what is design mode: Design pattern is a template that teaches you how to organize your code with real and reliable design. All the design Patterns ...