Adapter Pattern in PHP

Now we have covered all of the creational patterns you should know about (imo). I am steaming ahead on to the structural patterns. The first of which is the adapter pattern 😀

In programming, it’s not rare to build a system, to find out a few months down the line, there are a bunch of new requirements. Originally catering for a particular client or data set and then later having to cater for more and more, this is where the adapter pattern comes into play.

Continue reading

Builder Pattern in PHP

The builder pattern is another creational pattern, meaning its purpose is the creation of objects. Similar to the purposes of Singleton, Multiton and Factory patterns.

However the builder pattern will not only create objects, but prepare them for your application too. The builder pattern actually uses the factory method pattern behind the scenes, but I’ll get onto that soon.

Continue reading

Factory Pattern in PHP

The factory pattern is one of the most commonly used design patterns, something you’ll definitely be glad to have in your toolbox. It’s also pretty simple to get to grips with and start reaping the benefits.

The purpose of any factory class, is to create and return instances of other classes, just like a real world factory creates products. There are two types of factory design patterns. One is called the factory method and the other is called an abstract factory. There is another not official pattern called simple factory. All are described in detail below. Let’s get going.

Continue reading