Você está na página 1de 17

The CRC Card

Exercise

Java Boot Camp


OOP Concepts and Java Fundamentals

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Objectives
 To think in an object-oriented manner
 To use a responsibility-driven approach to
object-oriented development
 To run a CRC card session
 To use CRC cards in analysis and design

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
We need...
 3x5 or 4x6 index cards, or sheets of paper
cut to the same size
 Tape
 String
 People!

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
The CRC card

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
What is CRC
 Contains
 Classes
 Responsibilities
 Collaborators
 Facilitate open discussion of static
structure of a system
 Facilitate open discussion of dynamic
structure, the “what-if” exploration, by use
of object role play

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Classes
 Find all the nouns and verbs in the problem
statement
 Nouns are a good key as to what classes are
in the system
 Verbs show the responsibilities
 One class per card
 Each person is responsible for one class

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Superclasses and
Subclasses
 Can be defined at any time they become
obvious
 May be defined now or may wait until the
scenario does this

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Responsibilities
 Add the obvious
 From the requirements
 From the name of the class

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Collaborators
 Identify the classes that cooperate with
each other to provide a need

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
The Analysis Exercise 1/2
 This application will support the operations
of a technical library for an R&D
organization. This includes the searching
for and lending of technical library
materials, including books, videos, and
technical journals. Users will enter their
company ids in order to use the system;
and they will enter material ID numbers
when checking out and returning items.

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
The Analysis Exercise 2/2
 Each borrower can be lent up to five items.
Each type of library item can be lent for a
different period of time (books 4 weeks,
journals 2 weeks, videos 1 week). If
returned after their due date, the library
user's organization will be charged a fine,
based on the type of item( books P10/day,
journals P30/day, videos P50/day).
 Materials will be lent to employees with no
overdue lendables, fewer than five articles
out, and total fines less than P1000.

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Scenario # 1
 What happens when Juan dela Cruz, who
has no accrued fines and one outstanding
book, not overdue, checks out a book
entitles "Document, Your job depends on
it"?

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Scenario # 2
 What happens when Juan dela Cruz returns
the book "Document, Your job depends on
it" two days late? He has no other item
checked out and no acquired fines.

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Scenario # 3
 What happens when Annie Batungbakal
uses the search feature to look for the book
"Object-Oriented Software Engineering" of
which there are 2 copies available?

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Scenario # 4
 What happens when Zsa Zsa Zaturnnah
uses the search feature to look for the book
"Object-Oriented Analysis and Design with
Application" of which there is 1 copy
available and the database is down?

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
The Design Exercise
 New things to record on your cards
 Class attributes
 Break down the responsibilities into
subresponsibilities
 After the Collaborator class on your card list
the responsibility of the used class that is used
in the collaboration
 After the collaborating responsibilities on your
cards, list the data passed back by the
collaborating object in parenthesis.

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved
Acknowledgements
 Reflections on CRC cards for OO design
 http://www.cs.umu.se/~jubo/Meetings/OOPSLA01/Contributions/RBiddle.html

 Object oriented analysis and design using


CRC cards
 http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/crc_b/

Copyright 2008 Orange & Bronze Software Labs Ltd.Co. All Rights Reserved

Você também pode gostar