All Posts tagged as "Design Patterns"

Design Patterns in PHP: Adapters

The adapter pattern also referred as the wrapper pattern, I find that wrapper is a more fitting name since it describes clearly what this pattern does; it encapsulates the functionality of a class or object into a class with a common public interfaces.

WTF are: Service Contracts (Magento 2 Edition)

The Service layer allows modules to provide a well-defined public API and effectively hiding the business logic and preserving data integrity.

Design Patterns in PHP: Singletons

The singleton pattern is useful when we need to make sure we only have a single instance of a class for the entire request lifecycle in a web application. This typically occurs when we have global objects (such as a Configuration class) or a shared resource (such as an event queue).

Design Patterns in PHP: Using Factories

The factory pattern is a class that has some methods that create objects for you. Instead of using new directly, you use the factory class to create objects. That way, if you want to change the types of objects created, you can change just the factory. All the code that uses the factory changes automatically.

Playing with dependency injection in PHP

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.