Java Reference
In-Depth Information
Concept summary
■
verb/noun
Classes in a system roughly correspond to nouns in the system's description.
Methods correspond to verbs.
■
scenarios
Scenarios (also known as “use cases”) can be used to get an understanding of the
interactions in a system.
■
prototyping
Prototyping is the construction of a partially working system in which some
functions of the application are simulated. It serves to provide an understanding early in the
development process of how the system will work.
■
design pattern
A design pattern is a description of a common computing problem and a
description of a small set of classes and their interaction structure that helps to solve that
problem.
Exercise 13.18
Assume that you have a school management system for your school. In it,
there is a class called
Database
(a fairly central class) that holds objects of type
Student
.
Each student has an address that is held in an
Address
object (i.e., each
Student
object
holds a reference to an
Address
object).
Now, from the
Database
class, you need to get access to a student's street, city, and zip
code. The
Address
class has accessor methods for these. For the design of the
Student
class, you now have two choices:
Either you implement
getStreet
,
getCity
, and
getZipCode
methods in the
Student
class—which just pass the method call on to the
Address
object and hand the result back—
or you implement a
getAddress
method in
Student
that returns the complete
Address
object to the
Database
and lets the
Database
object call the
Address
object's methods
directly.
Which of these alternatives is better? Why? Make a class diagram for each situation and list
arguments either way.
Search WWH ::
Custom Search