Title: Class Model
1Class Model
2Source
- These slides are entirely based on Chapter 7 of
your textbook. However useful, reliance on just
one source has its problems - Your textbook is not the ultimate authority.
- Different people use the same terms for different
things. - A project manager needs to be able to use with
precision the right terms for a given audience. - The term Structural Modeling is not generally
accepted Class Model is preferred. Why? - The terms Class and Object are often confused
- The book uses the term Operations most use the
term Methods. Operations is better, but Methods
is the standard - Multiplicity symbols vary widely
- We owe CRC cards to Rebecca Wirfs-Brock.
- Her companys website is the source on CRC cards.
- CTTC challenge Find this website, download more
information, and share it with the class.
3Objectives
- Understand the relationship between the class
model and the use-case models - Be able to create CRC cards, class diagrams, and
object diagrams - Understand the rules and style guidelines for
creating CRC cards, class diagrams, and object
diagrams - Understand the process used to create CRC cards,
class diagrams, and object diagrams
4Structural Models
- Structural models represent the things, ideas, or
concepts, that is, the objects, contained in the
application domain of the problem.
Text, page 188
5Structural Models
- One important thing to remember is that, at this
stage of development, the structural model does
not represent software components or classes in
an object-oriented programming language, even
though the structural model does contain analysis
classes, operations, and relationships among the
analysis classes. The refinement of these
initial classes into programming level objects
comes later.
Text, pages 188-189
6Structural Models
- Typically, structural models are depicted using
CRC cards, class diagrams, and, in some cases,
object diagrams
Text, page 189
7Classes, Attributes, and Operations
- A class is a general template that we use to
create specific instances, or objects, in the
application domain - All objects of a given class are identical in
structure and behavior but contain different data
in their attributes
Text, page 189
8Classes, Attributes, and Operations
- An attribute of an analysis class represents a
piece of information that is relevant to the
description of the class
Text, page 189
9Classes, Attributes, and Operations
- An operation, is where the behavior of the class
will be defined. - In later phase, the operations will be converted
to methods. However, since methods are more
related to implementation, at this point in the
development we use the term operation
Text, page 189
10Relationships
- Generalization
- AKO as in An hourly employee is a kind of
employee - Superclass - Subclass
- Classification
- Aggregation
- A-part-of
- Association
- Verb
- Should make semantic sense
Text, page 190
11ako
Text, page 194
12A Part Of
My diamond is black, the books is white.
Why the difference?
Health Team
Doctor
Nurse
Text, page 194
13Verb
Patient
Appointment
Schedules
Text, page 194
14CRC cards
- Class-Responsibility-Collaboration cards
- The textbook cites three sources
- D. Bellin and S.S. Simone, The CRC Card Book
(Reading, MA Addison-Wesley, 1997) - I. Graham, Migrating to Object Technology
(Wokingham, England Addison-Wesley, 1995) - B. Henderson-Sellers and B. Unhelkar Open
Modeling with UML (Harlow, Englan
Addison-Wesley, 2000) - Rebecca Wirfs-Brock is generally recognized as
having introduced them
Text, page 191
15CRC cards responsibilities
- Knowing responsibilities
- An instance typically knows the values of its
attributes and its relationships - An instance may be responsible for knowing other
things as well - Doing responsibilities
- Those things that an instance of class must be
capable of doing
Text, page 191
16CRC cards collaborations
- Most use cases involve a set of several classes,
not just one class. - This set of classes forms a collaboration
- A collaboration is the set of classes involved a
use case - There is one for each use case
Text, page 191
17CRC cards collaborations
- Collaborations allow us to think in terms of
clients, servers, and contracts - A client object is an instance of a class that
sends a request to an instance of another class
for an operation to be executed - A server object is instance that receives the
request from a client object - A contract formalizes the interactions between
the client and server objects.
Text, page 192
18Anthropomorphism
- Pretending that the classes have human
characteristics - Also called The Animation Principle
- The idea is to use the CRC framework plus
play-acting to help identify - The classes
- Their attributes
- Their operations
- Their relationships
Text, page 192
19A Note on Sources
- The book here acknowledges several very important
sources among these please note these three - K. Beck and W. Cunningham, A Laboratory for
Teaching Object-Oriented Thinking, Proceedings
of OOPSLA, SIGPLAN Notices 24, no. 10 (1989)
(Kent Beck, Ward Cunningham, together with Ron
Jeffries, created Extreme Programming XP) - C. Larman, Applying UML and Patterns An
Introduction to Object-Oriented Analysis and
Design (Englewood Cliffs, NJ Prentice Hall,
1998) (Craig Larmans book, a classic, introduces
domain modeling, iterative design, and the use of
patterns to solve architectural problems) - R. Wirfs-Brock, B. Wilkerson, and L. Wiener,
Designing Object-Oriented Software (Englewood
Cliffs, NJ Prentice Hall, 1990) (This is the
book that put CRC cards on the map)
Text, page 192
20Elements of a CRC Card
- One per class
- Class name (a noun), ID, Type, description, list
of associated use cases - Lists the responsibilities (knowing and doing)
- Lists the collaborators (classes involved in the
associated use cases) - Lists the attributes (in back)
- Lists the relationships (in back)
Text, page 192
21Elements of a CRC Card
Text, page 193
22Elements of a CRC Card
Text, page 193
23Class Diagrams
- A CLASS
- Represents a kind of person, place , or thing
about which the system will need to capture and
store information - Has a name typed in bold and centered in its top
compartment - Has a list of attributes in its middle
compartment - Has a list of operations in its bottom
compartment - Does not explicitly show operations that
available to all classes
Class1
-attribute1
operation1()
Text, page 195
24Class Diagrams
- AN ATTRIBUTE
- Represents properties that describe the state of
an object - Can be derived from other attributes, shown by
placing a slash before the attributes name - The visibility of an attribute can be public (),
protected (), or private (-)
attribute name/ derived attribute name
Text, page 195
25Class Diagrams
- AN OPERATION
- Represents the actions or functions that a class
can perform - Can be classified as a constructor, query, or
update operation - Includes parentheses that may contain parameters
or information needed to perform the operation - The operations that are available to all classes
(e.g., create a new instance, return a value for
a particular attribute, or delete an instance)
are not explicitly shown within the class
rectangle
operation name ()
Text, page 195
26Class Diagrams
- AN ASSOCIATION
- Represents a relationship between multiple
classes, or a class and itself - Is labeled using a verb phrase or a role name,
whichever better represents the relationship - Can exist between one or more classes
- Contain multiplicity symbols, which represent the
minimum and maximum times a class instances can
be associated with the related class instance
1.. verb phrase 0..1
Text, page 195
27Object Diagrams
- An instantiation of all or part of a class diagram
Text, page 199
28Creating CRC Cards and Class Diagrams
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
Text, page 200-204
29Creating CRC Cards and Class Diagrams
- Textual Analysis (see Figure 7-6)
- Nouns classes
- Adjectives attributes
- Verbs operations and associations
- Common Object List
- Tangible things
- Incidents
- Interactions
- Patterns (see Figure 7-7)
- Collection of classes that solve recurring
problems
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
Text, pages 200-201
30Creating CRC Cards and Class Diagrams
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
- Perform Textual Analysis on the Use Cases and
other writings to identify candidate classes - Each Use Case defines a collaboration, which is
the collection of classes that interact in the
use case - Work on one collaboration at a time
- A class may belong to more than one collaboration
Text, pages 202-203
31Creating CRC Cards and Class Diagrams
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
- What are the tangible things associated with the
problem? - What incidents and interactions take place in
the problem domain? - It is possible to uncover additional roles
outside the use cases and other writings
Text, page 203
32Creating CRC Cards and Class Diagrams
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
- Each CRC card should be assigned to an
individual, who will perform the operations for
the class on the CRC card - As the performers play out their roles, the
system will tend to break down.
Text, page 203
33Creating CRC Cards and the Class Diagram
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
- Transfer from the CRC cards the responsibilities
as operations, and the attributes as attributes,
and draw the relationships as generalization,
aggregation, or association - Add the visibility of the attributes and
operations - Examine the model for additional opportunities
to use aggregation or generalization relationships
Text, pages 203-204
34Creating CRC Cards and the Class Diagram
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
- Review the class diagram for missing and/or
unnecessary classes, attributes, operations, and
relationships - Some analysts normalize the class diagram
Text, page 204
35Creating CRC Cards and the Class Diagram
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
- Use Figure 7-7 to see if a pattern applies
Text, page 204
36Creating CRC Cards and the Class Diagram
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
- A walk-through a formal presentation to another
group of analysts to go over the CRC cards and
the Class Diagram
Text, page 204
37Creating CRC Cards and the Class Diagram
- Object Identification
- Create CRC Cards
- Examine Common Object Lists
- Role-Play the CRC Cards
- Create the Class Diagram
- Review the Class Diagram
- Incorporate Patterns
- Review the Model
In each of these steps be sure to record new
information on the CRC cards as it is discovered.
This may require creating new CRC cards and
modifying the Class Diagram.
Text, page 204
38Deliverable V Body
- Structural Modeling (Ch 7) (40 points)
- Class Diagram (30 points)
- CRC cards (10 points)
- Behavioral Modeling (Ch 8) (30 points)
- Sequence Diagrams (10 points)
- Collaboration Diagrams (10 points)
- Statechart Diagrams (10 points)
- Workflow Diagrams (20 points extra credit)