21.08.2013 Views

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

Software Engineering for Students A Programming Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

152 Chapter 12 ■ Design patterns<br />

period of time, experienced programmers build up a large repertoire of memories of<br />

programming patterns such as this one.<br />

A number of patterns have been identified, given names, cataloged and documented<br />

in catalogs or books. These patterns are available <strong>for</strong> off-the-shelf use, just as classes<br />

are available in class libraries. <strong>Software</strong> engineering patterns are patterns on a larger<br />

scale than the simple program seen above. The established patterns specify the structure<br />

of useful software at the architectural level. In object-oriented development, this means<br />

structures expressed in terms of classes and their interrelationships.<br />

The strength of design patterns is that good design ideas are recorded, given a name,<br />

and explained with the aid of examples. This extends the vocabulary of software developers.<br />

It also extends the repertoire of ideas that they can use without reinventing the<br />

wheel.<br />

To make use of patterns, the software engineer needs some recollection of the standard<br />

patterns. This is obtained by browsing a patterns catalog prior to a project. The<br />

engineer thereby retains some memory (perhaps only a partial recollection) of the patterns,<br />

then, during the early phase of software architectural design, the engineer realizes<br />

that one or more patterns may be useful. They then consult the catalog to confirm<br />

the appropriateness of the pattern and see exactly how to use it. The next step is to use<br />

the pattern as part of the design.<br />

In summary the stages are:<br />

1. browse a design pattern catalog, to obtain some feel <strong>for</strong> the available patterns<br />

2. embark on a new design with an awareness of the patterns<br />

3. recognize the need <strong>for</strong> one of the established patterns<br />

4. consult the catalog to check the applicability of the pattern<br />

5. use the catalog <strong>for</strong> in<strong>for</strong>mation on the how to use the pattern<br />

6. use the pattern as part of the design.<br />

As well as architectural structure, patterns are available <strong>for</strong> such domains as user<br />

interfaces, file systems and multithreading. Patterns are also provided <strong>for</strong> activities such<br />

as testing and project management.<br />

In order to use design patterns the programmer needs considerable experience and<br />

understanding of OOD and OOP.<br />

Just as there are patterns (which are valuable structures) so there are anti-patterns,<br />

which are undesirable structures. The reason <strong>for</strong> identifying and cataloguing anti-patterns<br />

is to avoid them. We look at one such pattern.<br />

In this chapter we present a number of useful patterns and use the cyberspace<br />

invaders game as an example in explaining some of the patterns.<br />

12.2 ● Inheritance<br />

It bears repeating that one of the major goals of the object-oriented paradigm is to<br />

produce reusable software components – components which can be reused both<br />

within the application in which they were generated but also in future applications.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!