You are here

Design Patterns

Build a Navigation Menu Using Design Patterns

Download the source for the Navigation Menu.

Goal: This easy project will combine powerful tools with some simple components to produce a flexible navigation menu capable of displaying horizontally or vertically with never-ending submenus.

The Composite Pattern

Download the source for the Composite Pattern or get it on Github.

The Iterator Pattern

Download the source for the Iterator Pattern or get it on Github.

The Template Pattern

Download the source for the Template Pattern or get it on Github.

The Adapter Pattern

Download the source for the Adapter Pattern or get it on Github.

The Command Pattern

Download the source for the Command Pattern or get it on Github.

The Command Pattern is a design pattern implemented for a multitude of purposes: progress bars, wizards, thread pools, multi-level undo, and networking to name a few. By encapsulating the request as an object, the Command Pattern allows us to parameterize other objects with different requests, queue or log those requests, and even support undo functionality.

The Singleton Pattern

Download the source for the Singleton Pattern or get it on Github.

Sometimes you may find yourself in need of an object that can exist once and only once, for example: registry settings, device drivers, or game objects. To do this we use a pattern aptly named the Singleton Pattern. The Singleton utilizes a private constructor and so can only be instantiated through a call to another method. Here is a basic Singleton.class.php:

The Factory Pattern

Download the source for the Simple Factory Pattern or get it on Github.

The Decorator Pattern

Download the source for the Decorator Pattern or get it on Github.

Ever need to add new or additional functionality to a class dynamically? Need to make a class that is open for extension but closed for modification? Then the Decorator pattern is for you. How? Simple, we will add a new class to wrap, or decorate, the original class.

The Observer Pattern

Download the source for the Oberver Pattern or get it on Github.

Subscribe to Design Patterns