Gang of Four

Also known as Token Intent Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restored to this state later. Explanation Real-world example We are working on an astrology application where we need to analyze star properties over time. We are creating snapshots of star states using the Memento pattern. In plain words Memento pattern captures object internal state making it easy to store and restore objects in any point of time.
Also known as Dependents, Publish-Subscribe Intent Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. Explanation Real-world example In a land far away live the races of hobbits and orcs. Both of them are mostly outdoors so they closely follow the weather changes. One could say that they are constantly observing the weather. In plain words Register as an observer to receive state changes in the object.
Also known as Objects for States Intent Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. Explanation Real-world example When observing a mammoth in its natural habitat it seems to change its behavior based on the situation. It may first appear calm, but over time when it detects a threat, it gets angry and dangerous to its surroundings. In plain words
Also known as Policy Intent Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from the clients that use it. Explanation Real-world example Slaying dragons is a dangerous job. With experience, it becomes easier. Veteran dragonslayers have developed different fighting strategies against different types of dragons. In plain words Strategy pattern allows choosing the best-suited algorithm at runtime. Wikipedia says In computer programming, the strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm at runtime.
Template method
Intent Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure. Explanation Real-world example The general steps in stealing an item are the same. First, you pick the target, next you confuse him somehow and finally, you steal the item. However, there are many ways to implement these steps. In plain words
Intent Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates. Explanation Real-world example Consider a tree structure with army units. Commander has two sergeants under it and each sergeant has three soldiers under them. Given that the hierarchy implements the visitor pattern, we can easily create new objects that interact with the commander, sergeants, soldiers, or all of them.
Also known as Wrapper Intent Convert the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. Explanation Real-world example Consider that you have some pictures on your memory card and you need to transfer them to your computer. To transfer them, you need some kind of adapter that is compatible with your computer ports so that you can attach a memory card to your computer.
Also known as Handle/Body Intent Decouple an abstraction from its implementation so that the two can vary independently. Explanation Real-world example Consider you have a weapon with different enchantments, and you are supposed to allow mixing different weapons with different enchantments. What would you do? Create multiple copies of each of the weapons for each of the enchantments or would you just create separate enchantment and set it for the weapon as needed?
Intent Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. Explanation Real-world example Every sentence is composed of words which are in turn composed of characters. Each of these objects are printable and they can have something printed before or after them like sentence always ends with full stop and word always has space before it. In plain words