GofPatterns GofPatterns



Design Patterns  «Prev  Next»
Lesson 9

Design Patterns - Module Conclusion

This module introduced you to design patterns at a very high level.
You learned how design patterns make software development easier by providing you with a toolbox of solutions to common problems you encounter in object-oriented design.
The most common design patterns are divided into
  1. creational patterns that describe how objects are created;
  2. structural patterns that describe how objects and classes are combined into larger composite structures, and
  3. behavioral patterns that describe how objects and classes interact.

Here are several ways in which the design patterns in this module can affect the way you design object-oriented software, based on our day-to-day experience with them.
Studies of expert programmers for conventional languages have shown that knowledge and experience is not organized simply around syntax but in larger conceptual structures such as
  1. algorithms,
  2. datastructures and
  3. idioms
and plans for fulfilling a particular goal. Designers probably do not think about the notation they are using for recording the design as much as they try to match the current design situation against plans, algorithms, data structures, and idioms they have learned in the past.
Computer scientists name and catalog algorithms and data structures, but they do not often name other kinds of patterns. Design patterns provide a common vocabulary for designers to use to communicate, document,and explore design alternatives. Design patterns make a system seem less complex by letting you talk about it at a higher level ofabstraction than that of a design notation or programming language. In addition, design patterns raise the level at which you design and enable you to discuss design with your co-workers. Once you have absorbed the design patterns discussed on this website, your design vocabulary will almost certainly change. You will speak directly in terms of the names of the design patterns. Furthermore, you will find yourselfsaying things like, "Let us use Factory pattern for this situation" or, "Let us apply the" Decorator pattern.

Computer programs are designed to solve human problems. A process called dynamic programming is a technique for breaking down larger problems into smaller ones. The plan is to solve each smaller problem and then put everything back together into a single, larger solution.
Classic Computer Science Problems

Modularization

The process of decomposing a problem into small subproblems is the process of modularization. Just like the complexities of getting from your home to Moscow can be modularized into a set of yes/no questions, any other complex problem also can be modularized. Figure 2-9 illustrates this process.

Figure 2-9: Even the most complex problem can be broken into modules

In looking at modularization, you may be thinking that it does not look too difficult and you would be absolutely right. The more complex the problem, the more it makes sense to modularize it. Therefore, the initial reasoning in OOP programming, far from being complex, simplifies the complex. Even the most daunting programming problem can be solved by this divide-and-conquer[1] algorithm.

Next Module

The next module explores the Singleton pattern, one of the simpler design patterns. You will learn how Singleton classes allow you to place restrictions on what client programmers are allowed to create.
The course project will be continued by writing a Singleton class that manages the interaction of the different lights.

[1]divide-and-conquer: In computer science, divide and conquer is an algorithm design paradigm based on multi-branched recursion. A divide-and-conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same or related type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem.