1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Discovering classes

*

Look for external factors; interactions between objects (classes) and the world outside them. These help you to find the objects themselves. Look for boundaries in the real world. These are often reflected in your objects. Look for initialization and cleanup. These belong in constructors and destructors.

Look for things that are duplicated. Are there are two or more of some object? Might you someday want to add another one of these objects? Common interfaces belong inside an abstract base type.

Look for the smallest common denominator in the system. For a text editor, you sometimes want to edit characters, words, lines, blocks, files. This gives you a whole set of related objects and relationships.

Will this class work in other situations? Is it general? Which things stay the same? Which differ?

Look at the data. Group data that seems to belong together. Is this an object? Should this data be hidden or at least not be carelessly modified? Put it inside an object

Write a main program using the objects you have so far. Do you have everything you need?

*

*

*

*

*

22-Mar-98

Page 9

C201/TAM