“Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice”
Christopher Alexander
"Coding like poetry should be short and concise"
Santosh Kalwar
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
Martin Fowler
Provides an interface for creating families of related or dependent objects without specifying their concrete classes.
Separate the construction of a complex object from its representation allowing the same construction process to create various representations.
Define an interface for creating an object, but lets subclasses decide which class to instantiate.
Define an interface for creating an object, but lets subclasses decide which class to instantiate.
Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
Ensures a class has only one instance, and provides a global point of access to it.
"Software and cathedrals are much the same – first we build them, then we pray."
Samuel T. Redwine, Jr.
Converts the interface of a class into another interface the clients expects. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.
The bridge design pattern is used to decouple the interfaces from implementation and hiding the implementation details from the client program.
Used when we have to implement a part-whole hierarchy. For example, a diagram made of other pieces such as circle, square, triangle, etc.
The decorator design pattern is used to modify the functionality of an object at runtime.
Provides an unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.
Caching and reusing object instances, used with immutable objects.
Provides a surrogate or placeholder for another object to controll access to it.
"I’m not a great programmer; I’m just a good programmer with great habits."
Kent Beck
Achieves loose coupling in software design where a request from the client is passed to a chain of objects to process them.
Encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.
Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
Provides a centralized communication medium between different objects in a system.
When we want to save the state of an object so that we can restore later on.
Defines a one-to-many dependency between objects so that when one object changes state, all it’s dependents are notified and updated automatically.
Allows an object to alter its behavior when its internal state changes. The object will appear to change its class.
Defines a family of algorithms encapsulates each one, and make them interchangeable. Strategy lets the algorithm vary independetly from clients that use it.
Defines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.
Visitor pattern is used when we have to perform an operation on a group of similar kind of Objects.