How to use CRC cards for OO design

[Source: UML Distilled, Third Edition by Martin Fowler (Chapter 4: Sequence Diagrams)]

CRC (Class-Responsibility-Collaboration) Cards is a helpful technique to model a good object oriented design and to explore object interactions.

How to use CRC Cards

To use CRC cards, take various scenarios from your project and write them down on cards (a card can be just a piece of paper), then pick them up in any order that make sense to your team and move them to suggest how they send messages to each other and pass them around.

As you do this, you form ideas about responsibilities and write them on the cards. Thinking about responsibilities is important, because it eases the team members toward understanding the higher-level behaviour of each class.

crc

Figure: A sample CRC Card

 

Understanding the responsibilities of an object 

An important part of CRC thinking is identifying responsibilities. A responsibility is a short sentence that summarizes something that an object should do. It can be an action the object performs, some knowledge the object maintains, or some important decisions the object makes. The idea is that you should be able to take any class and summarize it with a handful of responsibilities. Doing that can help you think more clearly about the design of your classes.

Try to avoid writing down too many low-level responsibilities. The responsibilities should easily fit on one card. Ask yourself whether the class should be split or whether the responsibilities would be better stated by rolling them up into higher-level statements.

Collaboration with other classes

Here collaborators are the other classes that this class needs to work with. This gives you some idea of the links between classes— still at a high level.

Here is good online video by Simon Allardice that demonstrates how to use CRC Cards: