Java Reference
In-Depth Information
Exercise 13.7 Make a class design for an airport-control-system simulation. Use CRC
cards and scenarios. Here is a description of the system:
The program is an airport simulation system. For our new airport, we need to know
whether we can operate with two runways or whether we need three. The airport works
as follows:
There are multiple runways. Planes take off and land on runways. Air traffic controllers
coordinate the traffic and give planes permission to take off or land. The controllers
sometimes give permission right away, but sometimes they tell planes to wait. Planes
must keep a certain distance from one another. The purpose of the program is to simu-
late the airport in operation.
13.2
Class design
Now it is time for the next big step: moving from CRC cards to Java classes. During the CRC
card exercise, you should have gained a good understanding of how your application is struc-
tured and how your classes cooperate to solve the program's tasks. You may have come across
cases where you had to introduce additional classes (this is often the case with classes that rep-
resent internal data structures), and you may have noticed that you have a card for a class that
was never used. If the latter is the case, this card can now be removed.
Recognizing the classes for the implementation is now trivial. The cards show us the complete
set of classes we need. Deciding on the interface of each class (that is, the set of public methods
that a class should have) is a bit harder, but we have made an important step toward that as well.
If the playing of the scenarios was done well, then the responsibilities noted for each class de-
scribe the class's public methods (and maybe some of the instance fields). The responsibilities of
each class should be evaluated according to the class design principles discussed in Chapter 6:
responsibility-driven design, coupling, and cohesion.
13.2.1
Designing class interfaces
Before starting to code our application in Java, we can once more use the cards to make another
step toward the final design by translating the informal descriptions into method calls and add-
ing parameters.
To arrive at more formal descriptions, we can now play through the scenarios again, this time
talking in terms of method calls, parameters, and return values. The logic and the structure of
the application should not change any more, but we try to note down complete information
about method signatures and instance fields. We do this on a new set of cards.
Exercise 13.8 Make a new set of CRC cards for the classes you have identified. Play
through the scenarios again. This time, note exact method names for each method you call
from another class, and specify in detail (with type and name) all parameters that are passed
and the methods' return values. The method signatures are written on the CRC card instead
of the responsibilities. On the back of the card, note the instance fields that each class holds.
 
 
Search WWH ::




Custom Search