Selecting design patterns

Design patterns are intended to solve common design problems. These patterns provide guidelines for solving a design issue, and their techniques are proven to work. There are 23 original patterns, categorized into creational, structural, and behavioral patterns. Different design patterns exist for different types of known design issue. In this chapter, we discussed some commonly-used patterns in enterprise applications.

Design patterns introduce transparency and clarity to the system's design, and provide reusable constructs that help to build a better enterprise system. Selecting a design pattern from the set of patterns is important for solving a design issue that we are trying to solve.

The first thing that we need to do before selecting a pattern is to understand the problem and see whether it is related to object creation, or its behaviors, or how it has to be structured. We should then map this to the categories of the design patterns. Some problems may fall into more than one category and may require mix-and-matching more than one pattern.

Once we are clear on the type of problem we are trying to solve, the next thing that we need to do is understand what problems different design patterns solve. We need to understand the purpose of these patterns to see which patterns fit with the design problems that we are going to solve.

If the solution requires choosing between more than one pattern, we need to understand how these have to be interlinked for the problem that we are solving.

Once you're clear on the intent, prepare a model and try to establish a relationship between the classes and objects. We should then gain an understanding of how these classes and objects have to be composed and collaborated, and how they relate to each other. If required, we may have to reconsider the chosen patterns, providing implementations for them and maintaining consistency during this.

Patterns are there to aid design issues and provide templates for designing a system in a better way. Identifying the appropriate patterns in the context of the problem that we are trying to solve makes the solution easier and creates a common solution to addressing the problem, making it easier for other people to understand the design. We might already be following some of these patterns unknowingly in our system's design. However, having an understanding of the patterns—and their intent for solving design problems, recognizing a pattern in an existing system, and implementing these patterns—will make the system design cleaner and easier to maintain over time.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset