June 2002 Technical Tip – "Object Think"
The object-oriented paradigm is here to stay. Recent college IT-graduates have grown up with objects, and the object-oriented mindset seems natural to them. But for those of us who have been in this business since the days of punched cards, object-oriented thinking is often a difficult, sometimes painful change.
CRC cards are a popular technique for getting experienced systems professionals to change their way of thinking. CRC stands for class-responsibility-collaborator. CRC cards are used in a group setting with each participant taking a card and assuming the role of a class. A dialogue about the proposed system ensues and participants act the way their class is supposed to act, recording the work they are to accomplish (responsibilities) and who will help them in accomplishing that work (collaborators) on their cards.
CRC cards have their place, but I will go on record as stating that they will shortly fall out of favor. One problem with CRC cards is that they are designed for use with a group. Experienced professionals know how difficult it is to get a group together, and this is becoming even more difficult inspite of increased technology. While we recognize the synergistic benefits of a group effort, the increased costs often do not justify the benefits. Furthermore, as professionals become more experienced with the OO approach, the solution to systems will become more obvious. Indeed, CRC cards will go the way of program flowcharts: terrific for education, but not practical for use in the real world.
A practical alternative to CRC cards is "object think" (Coad and Nicola, 1993). Object thinking can be done individually – no group required. But before we discuss object think, let's review objects for the benefit of those readers who just aren't there yet.
An object is an entity with state and behavior. For example, a counter has a state (for example, the value is 2) and behavior (it can be incremented or decremented). The state is also referred to as attributes or fields, and the behavior is also referred to as methods or functions. A class is a template for creating objects. Here's a simple mnemonic: A + B = C, or attributes + behaviors = classes.
With object think, we let the object talk about itself. Specifically, the object says "This is what I know…" and "This is what I know how to do…" With the counter example, the object might say, "I know my value" and "I know how to increment myself". That which I know (or need to know) will become attributes, and that which I know how to do (or need to know how to do) will become behaviors.
"Object think" represents a very natural way to think of objects, and from that process we can design the classes which will be used to create those objects.
I first learned about "object think" in the following book, which I highly recommend as a very readable introduction to object-oriented technology: The Object-Oriented Approach (2ed), John W. Satzinger and Tore V. Orvik, Course Technology/Thomson Learning, (2001), ISBN 0-619-03390-8.