A design pattern is a common solution to a common problem. Nothing more, nothing less. And, while some of these approaches might seem foreign or overwhelming to you, the important thing to remember is that, as a developer, you are in charge. That means you decide when a pattern is appropriate, and when it's completely unnecessary. That's the key.
- The Decorator Pattern
A decorator allows us to dynamically extend the behaviour of a particular object at runtime, without needing to resort to unnecessary inheritance.
- Gettin' Jiggy With Adapters
Allows you to translate one interface for use with another. An adapter is one of the easier design patterns to learn. The reason why is because you use them in the real world all the time!
- The Template Method Pattern
Useful when worry about code duplication. I bet you've used the template method design pattern on multiple occasions without even realizing it! This is an easy one to understand.
- Pick a Strategy
Defines a family of algorithims encapsulate and make them interchangeable. Let's talk about the strategy design pattern and polymorphism. Like many patterns, you may find that you already use this one!
- The Chain of Responsibility
The chain of responsibility pattern is definitely an interesting one. It literally allows us to chain any number of objects, where each has the option of either handling a particular request, or deferring to the next object in the cycle.
- The Specification Pattern in PHP
Takes any kind of business rule and promotes it to a first class citizen e.g. Gold subscribers. Though certainly not for everything, you may find situations where the specification pattern can prove to be exactly what you need. Review the core concept, while using TDD and PHPUnit to drive our code.
- The Specification Pattern in PHP: Part 2
Figuring out how to apply this concept to database queries. Let's figure that out, while, in the process and learn how to use (and test) Eloquent outside of Laravel.
- Observe This, Fool
Create a one to many relationship so that when one object changes, its dependencies or observers are immediately notified. In that way they can then respond to this event that just occurred. This gives us a way for objects to notify one another without being linked. The observer pattern is easily one of the most popular patterns in the bunch. And, luckily, it's one of the easier ones to comprehend.