Java Reference
In-Depth Information
Exercise 13.16 Three further, commonly used patterns are the State pattern, the Strategy
pattern, and the Visitor pattern. Find descriptions of each of these, and identify at least one
example application for each.
Exercise 13.17 Late in the development of a project, you find that two teams who have
been working independently on two parts of an application have implemented incompatible
classes. The interface of several classes implemented by one team is slightly different from the
interface the other team is expecting to use. Explain how the Adapter pattern might help in this
situation by avoiding the need to rewrite any of the existing classes.
In this chapter, we have moved up one step in terms of abstraction levels, away from thinking
about the design of single classes (or cooperation between two classes) and toward the design
of an application as a whole. Central to the design of an object-oriented software system is
the decision about the classes to use for its implementation and the communication structures
between these classes.
Some classes are fairly obvious and easy to discover. We have used as a starting point a method
of identifying nouns and verbs in a textual description of the problem. After discovering the
classes, we can use CRC cards and played-out scenarios to design the dependences and com-
munication details between classes and to flesh out details about each class's responsibilities.
For less-experienced designers, it helps to play through scenarios in a group.
CRC cards can be used to refine the design down to the definition of method names and their
parameters. Once this has been achieved, classes with method stubs can be coded in Java and
the classes' interfaces can be documented.
Following an organized process such as this one serves several purposes. It ensures that
potential problems with early design ideas are discovered before much time is invested in
implementation. It also enables programmers to work on the implementation of several classes
independently, without having to wait for the implementation of one class to be finished before
implementation of another can begin.
Flexible, extendible class structures are not always easy to design. Design patterns are used to
document generally good structures that have proven useful in the implementation of different
classes of problems. Through the study of design patterns, a software engineer can learn a lot
about good application structures and improve application design skills.
The larger a problem, the more important is a good application structure. The more experienced
a software engineer becomes, the more time he or she will spend designing application struc-
tures rather than just writing code.
Terms introduced in this chapter
analysis and design, verb/noun method, CRC card, scenario, use case, method
stub, design pattern
Search WWH ::

Custom Search