Design patterns are a collection of best practices used by software developers, normally in OOP. Design patterns propose solutions to general problems faced by developers.
Gang of Four (GOF)
In 1994, Erich Gamma, Richard Helm, Raph Johnson and John Vlissides (best known as the Gang of Four) published a book titled Design Patterns – Elements of Reusable Object-Oriented Software introducing for the first time the concept of Design Patterns for Software Development. The main principles followed are:
- Program to an interface not an implementation.
- Favor object composition over inheritance.
Common Platform for developers
Design patterns provide a standard terminology and are specific to particular scenario.
Design patterns have been evolved over a long period of time and they provide best solutions to certain problems faced during software development. Learning these patterns helps unexperienced developers to learn software design in an easy and faster way.
Types of Design Patterns
There are 23 design patterns that can be classified in three categories: Creational, Structural and Behavioral patterns.
- Creational Patterns. These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new operator. This gives program more flexibility in deciding which objects needs to be created for a given use case.
- Structural Patterns. These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
- Behavioral Patterns. These design patterns are specifically concerned with communication between objects.