Design Patterns

Relevant categories: Software Architecture

When designing different software we might face problems that are structurally identical and repeating in many projects. Design Patterns are there to help with this scenario. They represent patterns for solving recurring problems. The design patterns are samples that guide us through solving problems. They do not intend to address the development of the whole application, but rather specific aspects of the architecture design. Design patterns are only used during the design phase. They mainly focus on the relation between classes according to the requirement of our software.

Design patterns are divided into different categories. Such categories include Structural Patterns, Creational Patterns and Behavioral Patterns. Design patterns are formed by concepts such as delegation, aggregation, consultation, classes, and inheritance. For example, there is a structural design pattern called façade in which an integrated interface is provided instead of different interfaces in a subsystem. This interface makes the subsystem easy to use and integrate. As another example, there is a creational design pattern named Singleton which specifies that each class has only one instance and there is only one point for approaching it.

Every design pattern has a documentation which depict in what context to use the design pattern, what forces it should solve, and what is the solution. There are many different ways for documenting design patterns, but some of them are used widely. One of the most important formats is represented by Gang of Four which includes answering to the questions below:

  1. What is the Pattern's name? (A unique name for identifying the pattern).
  2. Why is this pattern used?
  3. What other names is the pattern famous by?
  4. In what context can we use the pattern? According to what problems can we use this pattern? What are the forces?
  5. How is the pattern visualized? (We should show a graphical description of the pattern using a class diagram.)
  6. What are the names of all the classes and objects which were used in the pattern?
  7. How do the objects and classes interact with each other?
  8. What are the results of using this pattern?
  9. What is the solution of this pattern?
  10. What are the real examples of using this pattern?
  11. What are the related patterns to this pattern?

Using design patterns have the following key benefits:

  1. We can learn more from the thinking of other people.
  2. The implementation is faster by using design patterns.
  3. The coding will result in a cleaner program. So, the code will have higher readability for other programmers and architectures.
  4. By using design patterns the probability of losing major consideration falls down.


Links: