The collaborations of the class: What other classes does it
interact with? Interact is an intentionally broad term; it could
mean aggregation or simply that some other object exists that will perform
services for an object of the class. Collaborations should also consider the
audience for this class. For example, if you create a class Firecracker,
who is going to observe it, a Chemist or a Spectator? The former
will want to know what chemicals go into the construction, and the latter will
respond to the colors and shapes released when it explodes.
One of the great benefits of CRC cards is in communication. Its best done in real time, in a group, without computers. Each person takes responsibility for several classes (which at first have no names or other information). You run a live simulation by solving one scenario at a time, deciding which messages are sent to the various objects to satisfy each scenario. As you go through this process, you discover the classes that you need along with their responsibilities and collaborations, and you fill out the cards as you do this. When youve moved through all the use cases, you should have a fairly complete first cut of your design.
Before I began using CRC cards, the most successful consulting experiences I had when coming up with an initial design involved standing in front of a teamwho hadnt built an OOP project beforeand drawing objects on a whiteboard. We talked about how the objects should communicate with each other, and erased some of them and replaced them with other objects. Effectively, I was managing all the CRC cards on the whiteboard. The team (who knew what the project was supposed to do) actually created the design; they owned the design rather than having it given to them. All I was doing was guiding the process by asking the right questions, trying out the assumptions, and taking the feedback from the team to modify those assumptions. The true beauty of the process was that the team learned how to do object-oriented design not by reviewing abstract examples, but by working on the one design that was most interesting to them at that moment: theirs.
Once youve come up with a set of CRC cards, you may want to create a more formal description of your design using UML. You dont need to use UML, but it can be helpful, especially if you want to put up a diagram on the wall for everyone to ponder, which is a good idea (there is a plethora of UML diagramming tools available). An alternative to UML is a textual description of the objects and their interfaces, or, depending on your programming language, the code itself.
UML also provides an additional diagramming notation for describing the dynamic model of your system. This is helpful in situations in which the state transitions of a system or subsystem are dominant enough that they need their own diagrams (such as in a control system). You may also need to describe the data structures, for systems or subsystems in which data is a dominant factor (such as a database).
Youll know youre done with Phase 2 when you have described the objects and their interfaces. Well, most of themthere are usually a few that slip through the cracks and dont make themselves known until Phase 3. But thats OK. Whats important is that you eventually discover all of your objects. Its nice to discover them early in the process, but OOP provides enough structure so that its not so bad if you discover them later. In fact, the design of an object tends to happen in five stages, throughout the process of program development.