Design Patterns are general reusable solutions to commonly occurring problems in a given context. What it means is that if you design your program or structure it in such a way that it matches with a specific design pattern then you will not get into the problem that the design pattern solves. For example if there is a design pattern named XYZ and it solves the problem ABC and you structure your program as per the XYZ design pattern, your program will be free of the problem ABC.

Design Patterns are not specific and limited to only certain programming languages. Programming language is just a tool using which you create an application or software to solve a real world problem. Depending upon your requirements and preference you may choose any language that you like and you can apply design patterns to it. Design patterns are software engineering methodologies and guide lines that you can use to speed up the development process. Design patterns just use language features like inheritance, polymorphism to provide a specific pattern.  So although we will be discussing design patterns here in PHP context, the same patterns are also used in other platforms as well like Java, .NET,.  Only the implementation of design pattern differs depending upon the language features. If you are a J2EE developer then knowingly or unknowingly you have been using design patterns.  Ok, so much of talk, now we just need to know what the commonly occurring problems are and what design patterns are used to solve those problems.

To describe each pattern and the problem it solves in a single post will not be possible as it will get much lengthy. There are quite a number of design patterns out there. So we will look at the most commonly used design patterns in detail with examples on at a time. So this post is the first in the series of posts to come. It is just an introductory post to let you know that there will be an ongoing series of posts on design pattern here on Web Roxtar. Below is the list of design patterns we will cover. The list is not ordered in any specific way. Make sure you follow the articles once they have been posted.

Design Pattern

What it does

Singleton Lets you instantiate a single instance of class and provides a global access to it.
Factory Provides an interface to create similar objects from different base classes.
Builder Lets you define a class that handles the building of other complex objects.
Iterator Provides a way to access the elements of a collection (i.e. an object of objects) sequentially without exposing underlying presentation.
Adapter Acts as an adapter between an existing interface and the interface the client expects.
Decorator Attaches additional responsibilities to an object dynamically.
Observer Provides a way to watch state of a object and to notify its dependants when the object changes state.
Model View Controller Lets you separate data, business logic and presentation from each other.
Data Mapper Lets you minimize coupling between applications classes and its database.
Facade Provides a common interface for a set of interfaces in the sub system.
Registry Provides references to objects from a single object.
Visitor Lets you define operations to be performed on the elements of an object without changing their classes.
Proxy Acts as a proxy to intercept the access to an object.
Strategy Allows you to change the internal implementation of objects easily, dynamically.
Specification Allows you to validate if an object satisfies certain specified criteria and selects those elements that satisfy the specifications.
State Lets you change the behavior of an object depending upon its state.
Active Record Abstracts database access and operations to row level.
Table Data Gateway Abstracts database access and operations to table level.
Template Lets you define a template object that will be used for creating child objects.
Prototype Specifies kinds of object to create in a prototype object and create object instances copying this object.
Interpreter Analyzes an entity for key elements and  provides its interpretation depending upon those keys.
Mediator Lets you define a object to mediate interaction between a set of objects.