design patterns

Design Patterns – Observer

The Observer is a Behavioral Design Pattern often known as Dependents or the Publish-Subscriber pattern where the subject would be the publisher and observer would be the subscriber. It defines and maintains a dependency between objects. It is used to keep consistency, or where you don’t know who needs to be notified when your Subject Design Patterns – Observer

Design Patterns – Facade

Sometimes our programs become too complex and some objects are being difficult to use and many times these processes for being using an object are repetitive and almost the same. In these cases, we can provide a Facade and with it, we are able to hide unnecessary processes and provide to our users only what Design Patterns – Facade

Design Patterns – Abstract Factory

This Creational Pattern provides an interface to create families of related or dependent objects without specifying their concrete classes. This pattern could be used with other creational patterns, such as Factory Method, or could be implemented also using Prototype Pattern and a concrete factory could also be a singleton. Wow, that’s so much information in Design Patterns – Abstract Factory

Design Patterns – Adapter

This Structural Design Pattern is used to convert an interface of a class to a different form, this allows that some different classes could work together. It ‘s the perfect approach to be used with Third Parties objects. An adapter allows you to translate one interface for use with another. Adapters could be implemented using Design Patterns – Adapter

Design Patterns – Singleton

Let’s talk a bit about our first Creational Design Pattern, here is Singleton. This pattern is common used when you want only one instance of an object. Some frameworks such as Laravel have in your Service Container the possibility to register classes/objects as a singleton. It means that will have only one instance for these Design Patterns – Singleton

Design Patterns – Strategy

This Behavioral Design Pattern is really useful and solves one of most common problems in OOP that is “do things decoupled”, is related to the O of Solid Principles – Open to extension but closed for modification. If you programming to an interface doing composition instead of inheritance, you’re probably already using it frequently. This Design Patterns – Strategy

Design Patterns – Configuring the project

Let’s get started Firstly I will create our skeleton to go through patterns. The project will be available at https://github.com/diegosm/designpatterns Ok, after cloning this repository on my machine, lets create some folders and files, the structure should be like the image below: Then we will create our files: composer.json phpcs.xml phpunit.xml .gitignore Now is time Design Patterns – Configuring the project