Tag Archives: design patterns

Singleton Design Pattern

Issue no. 3 on design patterns: The singleton pattern. Whenever we need a place to save and retrieve data throughout a script without using globals the singleton pattern comes in handy. It allows only one instance of itself. What seems like a drawback is quite useful: Wherever in your source you instantiate such an object: [...]

Parameterized Factory Desing Pattern

The parameterized factory design pattern is an extension to the factory design pattern as you might have guessed, but here we can make the factory create different objects depending on the parameter passed to the create-method. Imagine your application is supposed to connect to a MySQL-DB or to a PostgreSQL-DB. Instead of creating different objects [...]

Factory Design Pattern

Design Patters part 1. I built these samples on PHP design patterns a while ago to make some friends write better code. They ignored it, so I give it to you. I hope they are self-explanatory. If not: Feel free to ask! First off: The factory design pattern. It encapsulates the creation of a class [...]