The Singleton Pattern


Software Design Patterns And How They Came To Be

Each new advance in the field of software engineering brings with it the promise to build better software. The positive impact made upon the software engineering profession by object-oriented analysis, design, and programming techniques cannot be denied. However, insufficient training and experience can, and usually does, result in poorly-designed systems that are impossible to maintain. How can you then, if you are a novice, best capitalize on and apply the lessons-learned by software developers who have come before you? The answer is — learn how to use software design patterns to build your application architectures.

What Exactly Is A Software Design Pattern?

A software design pattern is a form of knowledge reuse. Many extremely bright, talented software professionals working hard over the years to produce robust, reliable, flexible software architectures, noticed that for similar design problems they created similar design solutions. These similar design solutions consisted of a set of one or more related classes and object interactions. The real intellectual leap came when these engineers realized they could extract the essence of each design solution into a more general solution specification. These general solution specifications could then be readily reused and applied as the architectural basis of specific design solutions for the design problems they addressed. These general design specifications are referred to as software design patterns. When you apply software design patterns in your application architecture you are standing upon the backs of giants.

Origins

The term design pattern is borrowed from the work of an architect named Christopher Alexander. Alexander is not a software architect; he is a building architect, and his work has had a tremendous philosophical influence upon the software design patterns movement. In his book The Timeless Way Of Building, Alexander lists three things necessary to build good buildings and towns: 1) the timeless way, 2) the quality without a name (QWAN), and 2) the gate. The objective is to create a building that manifests the quality without a name. The QWAN is something you immediately recognize when experienced yet is impossible to describe exactly. The QWAN can be achieved by building using the timeless way. The timeless way is the process by which living buildings and towns are created by implementing, or in Alexander’s words, unfolding, one architectural design pattern at a time. Success in the application of the way depends upon the intensity of each pattern’s implementation. The gate is a pattern language of architectural features that have been proven through the ages to work well for certain applications. To achieve the QWAN you must pass through the gate in order to practice the timeless way.

Pattern Specification

A pattern language manifests itself as a catalog of design patterns. In their book Design Patterns: Elements of Reusable Object-Oriented Software , Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides ( referred to in the software community as the Gang-of-Four ) describe each design pattern according to the following template:

I will not completely describe the few patterns I discuss in this chapter according to the template shown in table 25-1. I do, however, urge you to refer to the references listed at the end of the chapter to learn more about software design patterns and how you can use them to build better software.

Table 25-1: Pattern Specification Template

Section Name

Comments

Pattern Name and Classification

The name of the pattern.

Intent

A description of the pattern’s purpose and use.

Also Known As

Other names the pattern may be known by.

Motivation

The problem the pattern is trying to solve.

Applicability

Under what situations the pattern should be applied.

Structure

A graphical representation of the pattern in a notational language like UML.

Participants

The pattern’s classes and/or objects and their responsibilities.

Collaborations

How a pattern’s participants execute their responsibilities.

Consequences

The ramifications of the pattern’s use.

Implementation

Advice on using the pattern.

Sample Code

Concrete pattern implementation example in a programming language like Java.

Known Uses

Examples of the pattern’s application in the real world.

Related Patterns

Closely-related design patterns.

Applying Software Design Patterns

Some software design patterns can be used stand-alone while others are meant to be combined with other patterns to form a complete solution. The best way to learn about design patterns is to review a design pattern catalog, such as that given in the book Design Patterns: Elements of Reusable Object-Oriented Software by the Gang-of-Four, to get a feel for the different types of patterns and their application.

You don’t have to be a pattern wizard to realize the benefits of using patterns in your programs. The rest of this chapter is devoted to showing you how four design patterns can be used to produce a robust, flexible application architecture.

Quick Review

Software design patterns are a form of knowledge reuse. Design patterns are general software architectural solutions to general software architectural problems. A design pattern serves as the basis for a specific solution implementation. A complete design pattern specification includes more than just a graphical representation. Some design patterns can be applied alone while others are meant to be combined with other design patterns.




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net