It is said that the concept of design patterns has its origins in Field Architecture. It can be defined as a reusable solution to a problem occurring (commonly) in software design. In the mid-80s, experimentations began to apply patterns to software programming, and it has continued to evolve and be used regularly since. This is no surprise, as there are quite a few benefits to it. With design patterns, you can speed up the development process, prevent small issues from coming up later, improve code and cut down on the cost of developing the software.
There are basically three categories of design patterns:
Class instantiation forms the basis of this design pattern. Creational pattern can be further divided into class-creational and object-creational patterns. In the former, inheritance is used by subclasses to determine the type of class instantiated, and in the latter, instantiation is delegated to the objects. Some examples of this type of pattern are Prototype, Factory Method and Object Pool.
In this type of pattern, classes and objects are used together to form larger structures. While, structural class pattern relies on inheritance to compose an interface, structural object pattern uses different objects to create a new functionality. Proxy, Adapter, Bridge and Private Class Date to name a few come under this classification.
Here, the is a focus more on algorithms and there is attention given to the communication between patterns. The behavioral pattern can be differentiated into a behavioral class pattern and a behavioral object pattern. In the first, inheritance is used to assign behavior among the classes, and in the second, object composition is used. Command, Template Method, Strategy and Interpreter come under this type of pattern.
There is a fourth and ‘not so popular’ type of design pattern, Concurrency pattern. Thread Pool, Thread Specific Storage and Read-Write Lock are examples of this.
While we have mentioned many design patterns that are used quite commonly, it is by no means a complete list of all available patterns. Some patterns have become more popular over time and have found a lot of use, when compared to others.
Though it is true that design patterns allow for the coding of stable and robust software systems, there has been some criticism as well. Namely, that it leads to inefficient solutions due to unnecessary duplication of code and can even target the wrong problem. All the design patterns come with their set of pros and cons. This makes it important to pick the right pattern to use. To do this, clearly identify and define the problem to be solved.