CRC Cards

By: Jeremy W. Sherman. Published: . Categories: OOD.

File under “old technique, still useful”: CRC cards

The core elements of an object system are an object, its responsibilities, and its collaborators. With just that info, you can start walking through scenarios.

You’ll note this doesn’t say anything about inheritance or protoypal delegation or whatever; that’s intentional:

The cards are being used as props to aid the telling of a story of computation. The cards allow its telling without recourse to programming language syntax or idiom.

Being able to pick up and hold a card, and thereby signal to yourself that you’ve become that actor, helps with getting in the object thinking groove:

We were surprised at the value of physically moving the cards around. When learners pick up an object they seem to more readily identify with it, and are prepared to deal with the remainder of the design from its perspective. It is the value of this physical interaction that has led us to resist a computerization of the cards.

In the modern HeaderDocful world, it’s useful to write the responsibilities and collaborators bits right into the class-level doc comment.

The “collaborators” bit is especially valuable for hinting at dynamic runtime context that can be hard to infer from static source text. The same info is handy in method docs (“called by X when Y happens”).