Client Hair Model Contract by cyy18689

VIEWS: 224 PAGES: 36

More Info
									CRC – What is it?



 Class
 Responsibilities
 Collaborations
CRC – 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
CRC – What is it?



 Collaboration – Request a service from
 another object to fulfill a responsibility


                    Contract
       client                   server
CRC – 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?
CRC – 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?
CRC – 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?
CRC – 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
CRC – 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)
CRC – Walk-through

          print                   1:printRequest(printer)
                         :File                                   :Print Server

user
                                       4:print(file)
       5:getContents()
                                                                     2:add(file)
                                              3:[printer available]getNextFile()



                     :Printer                                       :Queue

                   6:printContents()
CRC – 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
CRC – 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
CRC – 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
CRC – Finding Classes
 Use Requirements Specification
   No requirement specification?
     Write down goals of design
 Look for noun phrases
   Obvious classes/objects
   Obvious nonsense (Discard)
   Don’t know???
CRC – Finding Classes - Guidelines
1. Model physical objects
           Disks, printers
2. Model conceptual entities
           Windows, Files
3. 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.
4. 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.
CRC – Finding Classes - Guidelines
5. Be wary of sentences in the passive
   voice, or those whose subjects are not
   part of the system.
6. Model categories of classes. (Could be
   abstract superclasses.)
7. Model known interfaces to the outside
   world.
          User Interface
8. Model the values of attributes of objects,
   not the attributes. (Float, Wheel, etc.)
Drawing Editor Example

 Hand out Drawing Editor
 Requirements Specification
Drawing Editor Example

 Hand out Drawing Editor
 Requirements Specification
 Find Preliminary Classes
   Determine Noun Phrases
     Drawing 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 toolrectangle
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
Drawing Editor Example

1. Model physical objects


Mouse button – Probably an attribute of
  a mouse or an event
     Drawing 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 toolrectangle
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
Drawing Editor Example

2. 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?????
Drawing Editor Example

3. 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.
     Drawing 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 toolrectangle element
diagonally opposite corner       shape of the cursor       associated corner
ellipse element                  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
Drawing Editor Example

4. 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?
     Drawing 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 toolrectangle element
diagonally opposite corner       shape of the cursor       associated corner
ellipse element                  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                  rectangle
drawing element                  start point
Drawing Editor Example
5. 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
Drawing Editor Example

6. Model Categories
 Tool and Creation Tools
 Drawing Element
Drawing Editor Example

7. Model Interfaces
 User?
 User Interface? Yes-part of design
 phase
 Cursor?
 Time?
     Drawing 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 toolrectangle element
diagonally opposite corner       shape of the cursor       associated corner
ellipse element                  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                 rectangle
drawing element                  start point
Drawing Editor Example

8. 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?
     Drawing 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 toolrectangle element
diagonally opposite corner       shape of the cursor       associated corner
ellipse element                  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                 rectangle
drawing element                  start point
     Drawing 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
Drawing Editor Example

Record candidate classes on CRC
 card

     Class: Drawing
Drawing Editor Example

Finding Abstract Classes
   Determine shared behavior
   Look for common attributes
   Group related classes
 Drawing Editor Example

                            Tool




       Selection              Creation
         Tool                  Tool




   Ellipse             Line          Rectangle          Text
Creation Tool      Creation Tool    Creation Tool   Creation Tool
Drawing Editor Example

Record superclasses and subclasses


     Class: Creation Tool
   Tool
   Ellipse Tool, Line Tool, Rectangle Tool, Text Tool

								
To top