|
|
(18 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| '''==CRC CARDS=='''
| | please review our new wiki page |
|
| |
|
| |
|
| |
|
| == '''Introduction''' ==
| | http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch3_3j_cj |
| | |
| Class-Responsibility-Collaborator is a simple Object oriented Analysis technique. They are also used as a successful modeling and collaborating design of a system. It basically an index card used to represent a class of objects, their behavior and their interactions. The cards are created through scenarios, based on the system requirements that model the behavior of the system
| |
| CRC cards where introduced by Kent Beck and Ward Cunningham in there paper "A Laboratory for Teaching Object-Oriented Thinking" released in OOPLSA '89. There original purpose was to teach programmers the object-oriented paradigm.
| |
|
| |
| It consists of
| |
| | |
| 1. Class
| |
| | |
| 2. Responsibility
| |
| | |
| 3. Collaborator
| |
|
| |
| | |
| '''Class:'''
| |
| A class represents an abstract characteristics of things (or Objects) and its characteristics ( or attributes). It is a user defined data type which contains all the variables, properties and methods in it. A class name is present on the top of the CRC card.
| |
| | |
| '''Responsibility:'''
| |
| Responsibility indicates what a class knows or does. It is basically all the variables and methods a class has. A class can change the values of what it knows but not what other classes know. The responsibilities of a class are present on the left of the CRC card.
| |
| | |
| '''Collaborator:'''
| |
| With each responsibility you indicate which other classes you need to work with to fulfill it. This gives you some idea of the links between classes. The collaborators of a class are present on the right side of the CRC card.
| |
| | |
| == '''Why use CRC cards?''' ==
| |
| | |
| | |
| 1. They are portable. They can be used anywhere since they do not require computers.
| |
| | |
| 2. They give us a brief idea of how the system is modeled. They also explain how the system works with respect to different situations.
| |
| | |
| 3. They are a useful tool for teaching people the object-oriented paradigm.
| |
| | |
| 4. They can be used as a methodology themselves or as a front end to a more formal methodology such as UML.
| |
|
| |
| | |
| == '''Format ''' ==
| |
| | |
|
| |
| A standard CRC would look as follows. It has a class name at the top. The card is divided into two parts. The left part contains responsibilities and the right part contains Collaborators.
| |
| | |
| | |
| [[Image:Example1.jpg]]
| |
| | |
| | |
| Each class has its own CRC card. A CRC card might also be helpful in finding out about how classes collaborate like which class initiates the flow of data.
| |
| | |
| == '''Creating CRC cards''' ==
| |
| | |
| CRC card creation is an iterative brain-storming process. CRC cards are created following the below steps:
| |
| | |
| 1. Select a set of use cases:
| |
| Decide on how to design CRC cards as to work opposed to the object interaction diagrams or work in conjunction with object interaction diagrams. Select a set of use cases so that they are related to different object types.
| |
| | |
| 2. Label the Cards:
| |
| Just name the cards with distinct classes and name the initial responsibilities.
| |
| | |
| 3. Test various scenarios:
| |
| Test the scenarios, identify new classes, assign new responsibilities and add them to the class. In brain storming session, various responsibilities of classes are identified and named.
| |
| | |
| 4. Stress test the cards:
| |
| To achieve an efficient design, test the cards in various new scenario's that may arise. Design the cards such that only one card is added to the set. If there seems to be a need to create a new object, then add a new card.
| |
|
| |
| 5. Add cards, Let designs evolve:
| |
| Some cards added at the initial phase may seem unnecessary later, but as design evolves, add new cards and push inital cards aside.
| |
|
| |
| 6. Refine:
| |
| Factor out complexity. Remove any attributes if present in responsibilities. See the relationships between various cards. Improve the various collaborations.
| |
| | |
| 5. Example:
| |
| LIBRARY SYSTEM:
| |
| 1.The library system consists of students and staff borrowing books.
| |
| 2. The librarian is present.
| |
| 3. The library system needs to keep track of the books borrowed and returned.
| |
| The CRC cards are:
| |