next up previous
Next: Design Summary Up: Design - How It Previous: Who Does What?

Design Principles Summary

  1. Identify all 'knowing' and 'doing responsibilities'. Describe them in English. Group these into related sets; these will become your classes
  2. Identify classes. Mirror the 'natural structure' of the problem. Assign responsibilities from 1. to classes.
    1. Recall that we should assign 'knowing responsibilities' so that we only have one copy of the data
    2. Mentally simulate each task ('doing responsibility'). Identify sub-tasks. Assign sub-tasks to classes.
    3. Recall that we should assign 'doing responsibilities' so that we try not to 'do' the same thing in two different places.
    4. Recall that a method should accomplish a single task.

Note that this process is iterative: usually we aren't able to exactly identify all knowing and doing responsibilities right at the beginning. Later, when we're mentally simulating the program, we will usually discover new knowing and doing responsibilities that we need to add to our list. Often we will just be able to include them in classes that we've already designed, but in some cases we might have to create new classes.

The upshot is that we should take the specification, identify and assign responsibilities as well as possible, mentally simulate, identify and assign responsibilities, mentally simulate, identify and assign responsibilities, and so on. This process should observe the guidelines about knowing and doing responsibilities above, and should end when we have described all the knowing and doing responsibilities in sufficient detail that we could then give our design to someone else, and they could translate it into code.


next up previous
Next: Design Summary Up: Design - How It Previous: Who Does What?
Chris Trendall
Copyright ©Chris Trendall, 2001. All rights reserved.

2001-12-09