/design-patterns-in-php

design patterns in php code

Primary LanguagePHP

##Design Patterns in PHP## PHP中的设计模式代码
参考地址:Design Patterns in PHP


本代码参考了以上链接,并做了一些修改,测试结果详见我的博客(Design Patterns in PHP)


设计模式图解:

alt text

##Introduce## Patterns in php. Today we are going to talk about design patterns in web development, more precisely – in PHP. Experienced developers are probably familiar with this, but this article will be extremely useful for all novice developers. So, what is it – design patterns? Design Patterns aren’t analysis patterns, they are not descriptions of common structures like linked lists, nor are they particular application or framework designs. **In fact, design patterns are “descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context.” **

In other words, Design patterns provide a generic reusable solution to the programming problems that we encounter every day. Design patterns are not ready classes or libraries, that can be simply applied to your system, this is not a concrete solution that can be converted in to source code, design patterns are much more than that. They are patterns, or templates, that can be implemented to solve a problem in different particular situations. Design patterns help to speed up the development, as the templates are proven and from the developer’s position, only implementation is required. Design patterns not only make software development faster, but also encapsulate big ideas in a simpler way. Also, be careful not to use them in wrong places in order to avoid unpleasant situations. In addition to the theory, we also give you the most abstract and simple examples of design patterns.

“Each pattern describes a problem which occurs over and over again … and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without doing it the same way twice.” – Christopher Alexander

By now there are 23 different known design patterns, and they can be separated into three categories by purpose:

  1. Creational Patterns: used to construct objects such that they can be decoupled from their implementing system
  2. Structural Patterns: used to form large object structures between many disparate objects
  3. Behavioral Patterns: used to manage algorithms, relationships, and responsibilities between objects

alt text