As PHP expands to become the server-side program of choice among a significant
portion of programmers, professional techniques and programming structures need to
be incorporated. Design patterns, a concept borrowed from The Timeless Way of Build‐
ing by Christopher Alexander (Oxford University Press), refers to a general reusable
solution to a commonly occurring problem within a given context. In everyday develop‐
ment work, PHP programmers encounter “commonly occurring problems” in a soft‐
ware development context, and the use of PHP design patterns is a set of solutions to
“commonly occurring” PHP programming problems. Pure and simple, PHP design
patterns are tools used to deal with the reality of professional software development.
They are not libraries or templates but rather more general structures that can be used
to solve problems. I like to think of design patterns in the same way as I do the loop
structure. The loop is used when some kind of iteration is required. True, there are other
ways to deal with iteration, but a loop is a flexible tool that saves time in the development
process. (Besides, it’s a lot neater than writing the same line of code 10,000 times!)
Further, I do not feel constrained by design patterns as “canned solutions” any more
than a loop is a “canned solution” to iteration. Besides, I can use the loop structure in a
variety of ways in PHP ranging from for to while statements and everything in between.
Likewise, design patterns can be implemented in more than one way depending on the
exact nature of the problem being solved.