Thursday, August 17, 2006

CRC Cards - Lightweight Design Tools

Lately I've been thinking about ways that I can have my team spend a bit more time designing our coding solutions. One tool that came to mind was CRC cards.

What are CRC cards? I'm glad you asked...

As we currently use [CRC cards], all the information for an object is written on a 4" x 6" index card. These have the advantages that they are cheap, portable, readily available, and familiar. Figure 1 shows an idealized card. The class name appears underlined in the upper-left hand corner, a bullet- list of responsibilities appears under it in the left two-thirds of the card, and the list of collaborators appears in the right third.

And here's kinda what they might look like:

In other words, CRC cards are just a note card with a bunch of info about an object written on an index card. Once you have a stack of cards, you have a potential design. Then the fun really begins, as you validate various scenarios by using your cards. Naturally, as you work with your cards, you'll add, delete and edit them.

CRC cards appeal to me for a whole bunch of reasons. A few of which are:

  • They emphasize responsibilities of an object. Thinking about what an object is responsible for, to me, is probably its most critical aspect. It's the one guiding element that I find myself using to dictate what code should and shouldn't be present in the object, and whether I'm on the right track when coding.
  • The concept is lightweight. After a few minutes of playing with the idea, any developer should be able to crank out cards.
  • It's portable and accessible. Carrying around a stack of cards is so easy, everyone on the team can play along.
  • The technology is right: they are the perfect companion to my notepad, and are more portable than a whiteboard.

The other key aspect of CRC cards, besides their physical nature, is the notion of scenarios. It's one thing to have a stack of cards, however, what you need to make them useful are sessions where test out use cases by using the cards. The design sessions seem like they could be really valuable, and if all the CRC cards do is to provide a useful prop to maintain the discussion, they are probably worth the trouble.

I still have a bit more brainstorming to do before I'll have it sorted out as to how this can be implemented on my team. But my folks better watch out - they could end up with a stack of index cards on their desks before too long.

One parting question - how does the concept of CRC cards apply to other paradigms of programming? Say procedural, or functional. Could you extend the concept work with those approaches?

No comments:

Post a Comment