CSC/ECE 517 Fall 2012/ch1 w43

From Expertiza_Wiki
Jump to navigation Jump to search

Class-Responsibilty-Collaboration Cards

Class Responsibility Collaboration (CRC) cards are a brainstorming tool used in the design of object-oriented software. They were proposed by and Ward Cunningham and Kent Beck. They are typically used when first determining which classes are needed and how they will interact.


Introduction

CRC-cards are a lightweight approach to collaborative object-oriented modelling that has been developed as a tool for teaching object-oriented thinking to programmers. They have been used widely in various teaching and training contexts.

A CRC-card corresponds to a class. A responsibility is something the objects of a class know or do as a service for other objects. The responsibilities of the objects of a class are written along the left side of the card. A collaborator is an object of another class "helping" to fulfill a specific responsibility.

The back of the card can be used for a brief description of the class' purpose, comments and miscellaneous details.

The structure of a CRC-card is as shown below.

CRC cards are usually created from index cards on which there are written:

1. The class name

2. Its Super and Sub classes (if applicable)

3. The responsibilities of the class.

4. The names of other classes with which the class will collaborate to fulfill its responsibilities.

5. Author

Using a small card keeps the complexity of the design at a minimum. It focuses the designer on the essentials of the class and prevents her/him from getting into its details and inner workings at a time when such detail is probably counter-productive. It also forces the designer to refrain from giving the class too many responsibilities. Because the cards are portable, they can easily be laid out on a table and re-arranged while discussing a design with other people.

A common method to determine what cards should be created is to read a specification for the problem under specification and consider if each noun should be a class and if each verb should be a responsibility of the noun or class to which it belongs. Naturally, the existence of a noun or verb does not require a class or responsibility in the program, but it is considered a good starting point.


CRC Models

A CRC model is a collection of CRC cards that represent whole or part of an application or problem domain. The most common use for CRC models is to gather and define the user requirements for an object-oriented application. The figure below presents an example CRC model for a shipping/inventory control system, showing the CRC cards as they would be placed on a desk or work table. Note the placement of the cards: Cards that collaborate with one another are close to each other, cards that don’t collaborate are not near each other.



Creating a CRC model

The steps in creating a CRC model are:

1. Put together the CRC modeling team.

2. Organize the modeling room.

3. Do some brainstorming.

4. Explain the CRC modeling technique.

5. Iteratively perform the steps of CRC modeling.

6. Perform use-case scenario testing


Example of a CRC card

The CRC card for a class Book is as shown below:


A CRC card corresponds to a class. It describes the common properties of certain kinds of objects of interest in a particular problem. An object can be any abstract or real world entity. Each class must have a single, well-defined purpose that can be described clearly. The class-name is written across the top of the class with a short description of the purpose of the class written at the back of the card.

A responsibility is a service provided by an object of a class for other objects. It could either be something that must be done or something that must be known. For example, an object of class book might be responsible for checking itself out, knowing its title, etc. To do something, an object makes use of its own knowledge and if that is insufficient, it takes help from other objects(its collaborators). The responsibilities of an object are written on the left of the card.

The collaborators indicates which objects can be asked for help to fulfill a specific responsibility. An object of the collaborator class can provide further information required for the completion of a particular responsibility or it can also take over the parts of the original responsibility. For example, a book object will know if its overdue only if it knows the current date. The collaborators are listed to the right of the card.

Advantages of CRC cards

  • It’s simple and straightforward: You get a group of people together in a room and fill out a bunch

of index cards. Because of its simplicity you can explain CRC modeling to a group of people in 10 or 15 minutes.

  • Language independent: This approach is low-tech and independent of programming languages which makes it easy for collaborative modeling in teams with people from different backgrounds(analysts, developers, users, etc.)
  • Easy to test: Through scenarios and role-plays, it is possible to easily test alternative analysis and design models using different cards and different responsibilities. In this way, it is possible to perform a variety of tests long before the code is actually written.
  • Formal Analysis: CRC cards provide a basis for more formal analysis and design methodologies.
  • Life Cycle: CRC cards are useful throughout the life cycle.
  • Portable: CRC cards can be used anywhere, even away from the computer or office.
  • Increased user participation: Because users are actively involved in defining the model their

satisfaction with the work will be much greater

  • Ease of transition: CRC cards eases the transition from process orientation to object orientation .
  • Prototyping: CRC modeling and prototyping are both iterative processes in which users are greatly involved. It is very common to draw rough sketches of screens and reports during CRC modeling sessions.
  • Class diagramming: CRC modeling leads directly into class diagramming. CRC models and class diagrams show many of the same concepts.

Disadvantages of CRC cards

  • It is threatening to some developers:Many developers do not feel the need to work closely with the users as they feel that since they know the technology, they know the business too. This is, however, not true as the users also work with with the technology on a regular basis due to which there may be times when the users may know more than the developers themselves.
  • It is hard to get users together: There may be times when it would be difficult to get everyone together and to schedule a meeting. It would be better to limit the meetings to only a few key people.
  • CRC cards are limited: CRC models are just part of the definition of user requirements for an OO-application; you should also consider use cases, prototypes, and formal requirements documents.Furthermore, in most organizations it isn’t acceptable to simply submit a collection of index cards as your analysis deliverable.

CRC card tools

There are many CRC tools available which are implemented in the form of software packages that provide different types of services to the users. Some of them are discussed below.

Stickies

One of the most simplest ways to produce CRC cards is by using applications like Stickies on Mac OSX and Sticky Notes on Microsoft Windows 7. Both pieces of software can hold all the information that physical CRC cards contain.

Hot Draw

Hot Draw is a framework for developing drawing programs (programs that allow users to create pictures and graphics). Hot Draw is more of a genesis for CRC card design rather than any CRC-card application.

Originally started as an exercise in design pattern best-practices, this piece of software allows one to effectively create and organize CRC, at least in a rudimentary sense.

As Hot Draw is a framework, an application needs to be built that actually utilizes it. One such application is JHotDraw, developed in part by Erich Gamma of "http://en.wikipedia.org/wiki/Design_Patterns Gang of Four]" fame. As seen above, rectangles (cards) can be created, and the required lines and text can be filled in. To effectively move and group cards, all of the individual components (lines, texts, drawings) must be group. The software allows for color customization, but overall the software specialized application toward the creation of CRC cards is quite limited.

QuickCRC

Quick CRC is a commercial software development tool that has been developed by Excel Software to automate responsibility driven design of object-oriented software. It automates CRC cards for identifying classes, responsibilities and collaborations between objects by designing and simulating scenarios. Complex designs can be partitioned into multiple diagrams. The inheritance graph instantly shows the class structure of the evolving design. Quick CRC is supported on both Windows and Mac OS.

Software designers can quickly identify object classes, relationships and related information before writing code. CRC cards are well suited to agile methods or as a front-end to UML.


Quick CRC Tool
Quick CRC Tool


QuickCRC can generate a text or HTML coding specification, generate cards, attributes and responsibilities from selected words in a text file or selectively print CRC cards for a peer review. Design work is saved as an XML file.

QuickCRC can generate inheritance graphs from information on CRC cards. These diagrams concisely illustrate the big picture of a large project that might contain thousands of classes and hundreds of diagrams.

Inheritance Graph
Inheritance Graph

A few popular features used in this tool are :

  • A set of existing cards pop up and we can add subclasses and superclasses to existing classes.
  • This tool provides namespace support for partitioning the cards into different functional areas which can be used while listing specifications, printing cards or exporting information to other tools.
  • It can generate the inheritance graphs from the information on the CRC cards.
  • Linking cards and scenarios to foreign documents is made easy and thus they can be easily accessed with a single click of the mouse.
  • Information can be exported to other development tools as the CRC cards can be exported to MacA&D, WinA&D or QuickUML to auto-generate UML class diagrams.
  • It can generate a text or HTML coding specification, generate cards, attributes and responsibilities from selected words in a text file or selectively print CRC cards for a peer review. Design work is saved as an XML file.


Easy CRC

A tool that effectively consolidates the best use of CRC cards and sequence diagrams is the Easy CRC tool.EasyCRC is the only tool that focuses on CRC cards and scenarios unlike many other tools that focus more on the implementation view of the underlying system. The use of the Easy CRC tool is divided into two categories:

  • It helps in identifying the object, which are the CRC cards, from plain regular language.
  • It identifies the collaborators and responsibilities by simulating scenarios using sequence diagrams. This tool makes use of the .NET framework.

Easy CRC offers a vibrant text editor in which the entire description can be copy-pasted and the tool automatically picks out the noun in the description and lists them. We can select the most appropriate nouns from the list and add them to the noun list.We can also select the words that were not listed by the tool by highlighting the word and adding it to noun list.

There are two ways to update the responsibilities and collaborators in CRC diagram.

  • Firstly, Enter all the values manually.
  • Secondly, Draw the sequence diagrams first and from these diagrams the responsibilities and collaborators of a class would be identified and updated.


Software Ideas Modeler

Software Ideas Modeler is a lightweight and powerful CASE CASE tool by Dusan Rodina. It supports UML 2.2 diagrams and a lot of other ones. Software Ideas Modeler is freeware (for non-commercial use). Commercial user may use this software only after buying a license.

The tool initially shows up all the 14 types of diagrams it supports and asks to choose one among them. After selecting CRC diagram, a diagram toolbox is opened. From there we can select a new CRC card or a link and few other shapes are also provided. When a new CRC card is added, the name can be changed by clicking the name box. The propertied can be edited by double clicking the crc card. This opens up a property pop up box. All the required details can be filled up.

This tool is fairly simple to use and also allows the user to customize the card properties. It supports various types of automatic alignment for diagram elements. Diagram can be zoomed. There are also implemented standard functions as undo/redo and work with clipboard. Diagram elements can be styled (background color, text color, fonts, border), grouped, placed in layers. The tool also provides an additional feature of including the subclasses and superclass of the class in discussion. Every field value can be modified and renamed inline. This tool also provides a feature of customizing the text and style based on the class. The interesting feature of this tool is that one can attach comments to a CRC card and also link the comments along with the comments. One can also attach a Diagram Description to a card.

SWIdeasModeler Tool
SWIdeasModeler Tool

There is an export to raster image formats (BMP, GIF, JPG, PNG, TIFF), vector image formats (Windows Metafile, SVG) and PDF. There is also export to XML. There is an import from XML.Software Ideas Modeler - Wikipedia It also provides support for various languages. The application supports also style sets for the whole project. The diagrams can be exported to multiple image formats and vector formats like WMF, EMF, SVG and bitmap format PNG.

On the core ideas of CRC card use, namely in specifying classes, responsibilities, and collaborators, SIM was very effective. The user interface was rather intuitive, and adding and removing entries was handled through a simple property page. Software Ideas Modeler enhanced the CRC card functionality by allowing entry of subclass and superclass information, which may or may not be "too much" information depending on one's opinion on the required elements of a CRC card.


Visual Paradigm for UML

A CASE tool for UML diagrams is Visual Paradigm for UML . It supports thirteen types of diagrams.Type of diagram can be selected from Diagram navigator. The option to select CRC card diagram is found under requirements capturing tab.Selecting a new CRC card diagram opens up a new diagram toolbar. We can create cards by selecting CRC Card from diagram tool. A new CRC card appears on screen. The properties have to be edited. We can edit Card name (class name), Super classes, sub classes, its attributes, its responsibilities and its collaborators. Attributes and responsibilities may be added by right clicking on attributes or responsibilities heading and click on add attribute or responsibility. Name of attribute and description can be entered and while entering responsibility Name and its collaborator are entered.

Class-Responsibility Collaborator (CRC) card is designed for identifying classes and operations in object-oriented approach. Visual Paradigm for UML provides a CRC Card diagram for software team to brainstorm, records, analyze and maintain CRC cards in systematic and collaborative way. This tool is very easy to use and intuitive. It allows easy addition of responsibilities to a class. Along with this, all fields on a crd can be edited inline. Visual paradigm is a simple diagram tool.

Other than providing the common CRC-related functionalities, it has the following peculiarities:

  • Record audio to associate to a diagram.
  • Decide which portions of a CRC card are displayed (Responsibilities, Attributes etc.)
  • Directly generating java code in eclipse with the class diagram.
  • All properties in a CRC card must be edited inline. To edit, double click on the desired field, update its value, and click on the diagram background to confirm editing. (from here)
  • It can generate UML class diagrams automatically out of the CRD cards.
  • Cannot drag and drop values from one card to the other.


Comparison and Trade Off between tools

Most of the tools that we have discussed so far, provide the ability to record on each card the name, the responsibilities, and the collaborators of an object or class. Considering these and some main features, we can compare them as the below table suggests:

Tools feature comparison
Feature QuickCRC VP UML SIM HD Stickies
Model scenarios
Drag values from card to card
Generate UML class diagrams
Handle subdiagrams
Generate Java code
Collapse/expand cards
Display/hide parts of a card
Export/import card diagrams to/from text files
Arrange cards based on different criteria
Analyze text to extract classes, responsibilities and attributes
Reverse engineer existing source code

Conclusion

CRC modeling is a very effective technique for identifying and validating user requirements. It works hand in hand with use cases and prototypes, and leads directly into class modeling. Using CRC cards, one can speculate the various possible designs, ensure that they are concrete and establish an explicit relationship between objects. This makes it easier to understand, evaluate, and modify a design.

One of the major problem for using this is the integration of the cards with larger and more complex design methodologies and with particular language environments. The need to retain the value of physical interaction points to the need for a new kind of user interface and programming environment as far beyond what we have today as our current systems are beyond the tool-oriented environments of the past.

See Also

  1. MetaModeling
  2. CRC and Scenario
  3. Object Oriented Thinking
  4. Requirement Analysis

References