Title: CRC%20
1CRC What is it?
- Class
- Responsibilities
- Collaborations
2CRC What is it?
- Classes - a group of objects with similar
attributes and methods - DOGS - Object - an instance of a class - SPOT
- Attributes - facts belong to an object - SPOT is
brown, short hair - Relationships - an association between objects -
SPOT to OWNER
3CRC What is it?
- Collaboration Request a service from another
object to fulfill a responsibility
Contract
client
server
4CRC Phase 1
- Find the Objects
- Model the domain
- What must the system accomplish?
- What behavior is clearly outside the system?
- For each goal, what kinds of objects are needed
to accomplish it?
5CRC Phase 2
- Determine their Responsibilities
- What does each object have to know in order to
accomplish each goal it is involved with? - What steps towards accomplishing each goal is it
responsible for?
6CRC Phase 3
- Determine Collaborations
- With whom will each object collaborate in order
to accomplish each of its responsibilities? - What other objects in the system hold knowledge
it needs, or know how to perform some operation
it requires? - What is the exact nature of the collaborations
between the objects?
7CRC Summary
- Objects become clients and servers within a
system - Responsibilities become contracts between them
- Collaborations are a way of determining which
clients and which servers are bound by which
contracts
8CRC Walk-through
- Goal
- For a given network, print different kinds of
files (Text File, Formatted File, Graphics File)
to different kinds of printers (Dot Matrix
Printer, Laser Printer)
9CRC Walk-through
print
1printRequest(printer)
Print Server
File
user
4print(file)
5getContents()
2add(file)
3printer availablegetNextFile()
Printer
Queue
6printContents()
10CRC Walk-through
- Classes
- File and subclasses Text File, Formatted File,
and Graphics File - Printer and subclasses Dot Matrix Printer and
Laser Printer - Print Server
- Queue
11CRC Walk-through
- Responsibilities
- File
- know how to print itself
- know how to send contents to Printer
- Print Server
- know how to respond to requests to print a file
- know the printers on the network
- Printer
- know how to print the contents of a File
- know its printing status
- know its printing capabilities
- Queue
- know how to respond to request to add and remove
files - know how many files it contains
12CRC Walk-through
- Collaborations
- To fulfill print itself, File is a client of
Print Server - To fulfill print request, Print Server is a
client of Queue and a client of Printer - To fulfill print contents, Printer is a client
of File
13CRC Finding Classes
- Use Requirements Specification
- No requirement specification?
- Write down goals of design
- Look for noun phrases
- Obvious classes/objects
- Obvious nonsense (Discard)
- Dont know???
14CRC Finding Classes - Guidelines
- Model physical objects
- Disks, printers
- Model conceptual entities
- Windows, Files
- If more than one word is used for the same
concept, choose the one that is most meaningful
in terms of the rest of the system. - Be wary of the use of adjectives. If the use of
the adjective in conjunction with the noun
implies different object behavior, then make a
new class. -
15CRC Finding Classes - Guidelines
- Be wary of sentences in the passive voice, or
those whose subjects are not part of the system. - Model categories of classes. (Could be abstract
superclasses.) - Model known interfaces to the outside world.
- User Interface
- Model the values of attributes of objects, not
the attributes. (Float, Wheel, etc.) -
16Drawing Editor Example
- Hand out Drawing Editor Requirements
Specification
17Drawing Editor Example
- Hand out Drawing Editor Requirements
Specification - Find Preliminary Classes
- Determine Noun Phrases
18Drawing Editor Example
List of Preliminary Candidates for
Classes drawing editor cursor stop
point interactive graphics editor element line
creation tool user current selection end
point drawing control point rectangle
creation tool line text creation
tool rectangle diagonally opposite corner shape
of the cursor associated corner ellipse I-beam
ellipse creation tool text position point
tool character major radius mode of
operation mouse button width of the
rectangle editor text element minor
radius time corner height of the
rectangle selection tool region bounding
rectangle creation tool crosshair drawing
element start point
19Drawing Editor Example
- Model physical objects
-
- Mouse button Probably an attribute of a mouse
or an event
20Drawing Editor Example
List of Preliminary Candidates for
Classes drawing editor cursor stop
point interactive graphics editor element line
creation tool user current selection end
point drawing control point rectangle
creation tool line text creation
tool rectangle diagonally opposite corner shape
of the cursor associated corner ellipse I-beam
ellipse creation tool text position point
tool character major radius mode of
operation mouse button width of the
rectangle editor text element minor
radius time corner height of the
rectangle selection tool region bounding
rectangle creation tool crosshair drawing
element start point
21Drawing Editor Example
- Model conceptual entities
- Useful entities line, rectangle, ellipse,
text, character, drawing element, drawing - Tool composed of selection tool creation
tool (four kinds of creation tool) - Current selection user manipulates it
- Point, Start point, end point, corner (different
kinds), major and minor radius, height width of
rectangle, bounding rectangle?????
22Drawing Editor Example
- One word for One concept
- Drawing editor, interactive graphics editor, or
just editor? - Drawing element or element?
- Text or Text Element?
- Append Element to line, rectangle, ellipse.
23Drawing Editor Example
List of Preliminary Candidates for
Classes drawing editor cursor stop
point interactive graphics editor element line
creation tool user current selection end
point drawing control point rectangle
creation tool line element text creation
tool rectangle element diagonally opposite
corner shape of the cursor associated
corner ellipse element I-beam ellipse
creation tool text position point tool c
haracter major radius mode of operation mouse
button width of the rectangle editor text
element minor radius time corner height of
the rectangle selection tool region bounding
rectangle creation tool crosshair drawing
element start point
24Drawing Editor Example
- Watch out for adjectives
- Do selection tool and the various creation tools
behave differently? - Rectangle, Bounding Rectangle, Region?
- Point, stop point, end point, control point?
- Corner, diagonally opposite corner, associated
corner?
25Drawing Editor Example
List of Preliminary Candidates for
Classes drawing editor cursor stop
point interactive graphics editor element line
creation tool user current selection end
point drawing control point rectangle
creation tool line element text creation
tool rectangle element diagonally opposite
corner shape of the cursor associated
corner ellipse element I-beam ellipse
creation tool text position point tool c
haracter major radius mode of operation mouse
button width of the rectangle editor text
element minor radius time corner height of
the rectangle selection tool region bounding
rectangle creation tool crosshair rectangle
drawing element start point
26Drawing Editor Example
- Watch out for sentences with no clear subject
- The current selection is indicated visually by
displaying the control points for the element - Who is displaying the control points for the
current selection? - the user can create an element of the selected
kind. - Creation tool classes can be regarded as
stand-ins for the user
27Drawing Editor Example
- Model Categories
- Tool and Creation Tools
- Drawing Element
28Drawing Editor Example
- Model Interfaces
- User?
- User Interface? Yes-part of design phase
- Cursor?
- Time?
29Drawing Editor Example
List of Preliminary Candidates for
Classes drawing editor cursor stop
point interactive graphics editor element line
creation tool user current selection end
point drawing control point rectangle
creation tool line element text creation
tool rectangle element diagonally opposite
corner shape of the cursor associated
corner ellipse element I-beam ellipse
creation tool text position point tool c
haracter major radius mode of operation mouse
button width of the rectangle editor text
element minor radius time corner height of
the rectangle selection tool region bounding
rectangle creation tool crosshair rectangle dr
awing element start point
30Drawing Editor Example
- Model values of attributes, not attributes
themselves - Height of Rectangle, Width of Rectangle?
- Major radius, minor radius?
- Position?
- Mode of Operation?
- Shape of the cursor?
- Corner?
31Drawing Editor Example
List of Preliminary Candidates for
Classes drawing editor cursor stop
point interactive graphics editor element line
creation tool user current selection end
point drawing control point rectangle
creation tool line element text creation
tool rectangle element diagonally opposite
corner shape of the cursor associated
corner ellipse element I-beam ellipse
creation tool text position point tool c
haracter major radius mode of operation mouse
button width of the rectangle editor text
element minor radius time corner height of
the rectangle selection tool region bounding
rectangle creation tool crosshair rectangle dr
awing element start point
32Drawing Editor Example
Summary of Remaining Candidate Classes Character
Ellipse Creation Tool Rectangle Element Control
Point Ellipse Element Selection Tool Creation
Tool Line Creation Tool Text Creation
Tool Current Selection Line Element Text
Element Drawing Point Tool Drawing
Editor Rectangle Drawing Element Rectangle
Creation Tool
33Drawing Editor Example
- Record candidate classes on CRC card
Class Drawing
34Drawing Editor Example
- Finding Abstract Classes
- Determine shared behavior
- Look for common attributes
- Group related classes
35Drawing Editor Example
Tool
Creation Tool
Selection Tool
Rectangle Creation Tool
Line Creation Tool
Ellipse Creation Tool
Text Creation Tool
36Drawing Editor Example
- Record superclasses and subclasses
Class Creation Tool
Tool
Ellipse Tool, Line Tool, Rectangle Tool, Text Tool