Java Reference
In-Depth Information
9.
Consider the BankAccountTester class of Chapter 3 . Which classes
does it depend on?
H OW T O 12.1: CRC Cards and UML Diagrams
Before writing code for a complex problem, you need to design a solution. The
methodology introduced in this chapter suggests that you follow a design process
that is composed of the following tasks:
1.
Discover classes.
2.
Determine the responsibilities of each class.
3.
Describe the relationships between the classes.
CRC cards and UML diagrams help you discover and record this information.
Step 1 Discover classes.
Highlight the nouns in the problem description. Make a list of the nouns. Cross out
those that don't seem reasonable candidates for classes.
Step 2 Discover responsibilities.
Make a list of the major tasks that your system needs to fulfill. From those tasks,
pick one that is not trivial and that is intuitive to you. Find a class that is
responsible for carrying out that task. Make an index card and write the name and
the task on it. Now ask yourself how an object of the class can carry out the task. It
probably needs help from other objects. Then make CRC cards for the classes to
which those objects belong and write the responsibilities on them.
Don't be afraid to cross out, move, split, or merge responsibilities. Rip up cards if
they become too messy. This is an informal process.
541
542
You are done when you have walked through all major tasks and are satisfied that
they can all be solved with the classes and responsibilities that you discovered.
Step 3 Describe relationships.
Search WWH ::




Custom Search