Chapter 13
Designing Applications

Modified

Overview

Chapter 13 discusses how to analyze and design solutions - that is, determine the classes and methods. One approach, CRC cards, is examined.

13.1 Analysis and design

Often the hardest part of developing a computer solution is analyzing the problem and designing a solution. There are many different approaches to problem solving but analysis and design often represent the first two steps to solving a complex problem. The following lists a common sequence:

There are six main steps to the Program Development Cycle:

  1. Analyze : Define the problem.
  2. Design: Plan the solution to the problem.
  3. Choose the interface: Determine how the program user will provide input and receive output.
  4. Code: Translate the algorithm into a programming language.
  5. Test and Debug: Locate and correct any errors.
  6. Complete the documentation: Organize all the material that describes the program.

13.1.1 The noun/verb method

nouns - ticket machines, tictactoe, clocks etc. correspond to classes. 
verbs - play, get price, print ticket, etc. correspond to methods. 

13.1.2 The cinema booking example

Analyze by describing the problem then marking nouns and verbs (nouns underlined, verbs in bold):

Exercise 1 - Discovering classes
Gin Rummy

The game uses a standard deck of 52 cards. There are two to four players. The deck is shuffled. The dealer deals five cards to each player. The game prints the cards of each player.

  • Underline the nouns.
  • Circle the verbs.
Exercise 2 - Discovering classes
  • What are obvious classes.
  • What are obvious methods for those classes.
Exercise 3 - Writing classes
  • Give the fields for some of the classes.
  • Give the constructor for some of the classes.
  • Give some methods.

13.10 Summary