A CRC Description of HotDraw

CRC Cards are a way of describing objects. One writes on index cards the responsibilities and collaborators one expects for each class used in a program. These are the first CRC Cards ever made. I wrote them early one morning years ago after I had been sleeplessly considering how to give students a feel for object design. The cards document HotDraw, a drawing editor written in Smalltalk by myself and Kent Beck.

We start with the usual model, view and controller.

Drawings hold Figures. Here is the abstract class and a few refinements. I chose these particular kinds of Figures to illustrate additional responsibilities assumed in refinement.

Note that BoxFigure is defined by attributes. I knew that these were weaker than responsibilities, but, wanted to show the versitility of paper in handling the occasional diagram.

The DrawingController collaborates with Tools to make changes. I didn't make a card for abstract Tool since it didn't carry any responsibility I felt needed recording. The class naming conventions implies its existence.

The SelectionTool can touch and drag both Figures and Handles. Tools and Handles both manipulate Figures. That makes Handles a wonderful little unit of extension that looks like a Figure to a Tool and like a Tool to a Figure.

Finally, Locator is a Point substitute that knows how to propagate changes between related figures. For example, when a Line connects to the corner of a BoxFigure and the BoxFigure moves, an update message propagates through a Locator to the Line.

Actually HotDraw didn't have Locators. Instead it had special cases that dealt with the change propagation. When I was drawing the cards the idea of a Locator just came to me. I've since used them effectivly in reimplementations of HotDraw.

So these are the original CRC Cards. I could tell as I was writing them that I was on to something good. I've recently reflected on this early experience in a position statement for the OOPSLA '94 Workshop on Teams & Objects. There's also related information accessable from our home page.

Copyright 1994, Ward Cunningham
All Rights Reserved.