Posts Tagged ‘oop’

The Chain-of-Command Pattern: OOP Techniques in PHP

The chain-of-command pattern, like most others, assists with maintaining a loose coupling within your classes. By providing a series of classes that implement the ICommand interface and do a specific bit of processing, the developer doesn’t have to care which method to execute.

Read More ...
 

The Observer Pattern: OOP Techniques in PHP

The observer pattern provides another way to maintain loose coupling within your code. It’s an extremely simple pattern and is implemented similarly across languages. There are two parts: the observer and the observable object. Let’s address them both starting with the observer.

Read More ...
 

The Iterator Pattern: OOP Techniques in PHP

The iterator pattern is one of the most useful, yet unused patterns defined. It provides a way for class users to count and iterate over a set of objects related to the class. This is very useful in MVC (Model-View-Controller) models as they handle data and the logic that pertains to it.

Read More ...
 

The Factory Pattern: OOP Techniques in PHP

The purpose of the factory pattern is to assist with maintaining loose coupling. Code that is tightly coupled is error prone in that if a class is changed, it can have a domino affect to other scripts using it. This is typical to large-scale systems and smaller systems that grow very fast.

Read More ...
 

The Singleton Pattern: OOP Techniques in PHP

The singleton pattern is a common pattern used to make resources exclusive in that there is one of a particular type of resource. The most common usage of this is database connectivity. Typically, an application only wants a single connection to a single database server at any given time. This is where the singleton pattern comes in.

Read More ...