Category: design-patterns

Among the new features and fixes that come with PHP5.4 we have the addition of traits to the PHP language, PHP is a single inheritance language this means that classes and only inheriting from single parent class, in practice this complicates code organization and can lead to code duplicity.

Languages...

The singleton pattern is used to restrict the instantiation of a class to a single object, which can be useful when only one object is required across the system.

Singletons are...

The factory pattern is one of the most commonly used Design Patterns, it is useful when we need to choose between several interchangeable classes at runtime. By using factories we are also separating the creation of an object from the actual implementation.

We can define a factory as a simple...

Dependency Injection is a software design pattern that allows avoiding hard-coding dependencies and makes possible to change the dependencies both at runtime and compile time.

By using Dependency Injection we can write more maintainable, testable, and modular code. All projects have dependencies. The larger the project the more dependencies is...