CSC/ECE 517 Fall 2012/ch1 w43: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 130: Line 130:
|[[File:517px-EasyCRC1.png|x300px]]
|[[File:517px-EasyCRC1.png|x300px]]
|}
|}
== Software Ideas Modeler ==

Revision as of 23:19, 3 October 2012

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 program being designed 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

Disadvantages of CRC cards

CRC card tools

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