7.4.  Design Patterns

[ fromfile: designpatterns.xml id: designpatterns ]

Design patterns are efficient and elegant solutions to common problems in object-oriented software design. They are high-level abstract templates that can be applied to particular kinds of design problems.

In their influential book,Design Patterns [Gamma95], Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, often (affectionately) referred to as the "Gang of Four", analyzed 23 specific patterns. Each pattern has a section devoted to it, describing the following things.

Design patterns are used for many different purposes. Most describe how to separate code by responsibility. They are subdivided into three categories: Creational, Structural, and Behavioral. Structural patterns describe how to organize objects, and connect them together. Behavioral patterns describe how to organize code. Creational patterns describe how to organize code that manages object creation.

The Gang of Four assert that design patterns are "descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context." As you continue to develop applications with Qt, you will see descriptions and examples of several design patterns.

Some of the commonly encountered design patterns arose from working around limitations in the more popular languages and APIs that were in use at the time they were cataloged. On the other hand, a modern, dynamic language like Python, has built-in support for several design patterns already, so implementing them in your own software is a natural benefit of learning that language. The same is true for Qt. You will work with several Qt classes that implement particular design patterns.