Sie sind auf Seite 1von 24

Software Engineering Lab

2006-04-12
1
SE LAB
KAIST
Tae-Hoon Song
CH3. Class Modeling
Michael Blaha, J ames Rumbaugh
Object-Oriented Modeling and Design with UML
2006-04-12 2/23
KAIST
Software Engineering LAB
Contents
Introduction
Background
Object and class concepts
Link and association concepts
Generalization and inheritance
Navigation of class models
Summary
2006-04-12 3/23
KAIST
Software Engineering LAB
Introduction
Object-oriented modeling and design
Way of thinking about problems using models
organized around real-world concepts
Class modeling
Describe the static data of objects and their
relationships to one another
Define each concept
Present the corresponding UML notation
2006-04-12 4/23
KAIST
Software Engineering LAB
Background
Model
Abstraction of something for purpose of
understanding it before building it
Viewpoints
Class model
Structure of objects in a system (class diagram)
State model
Aspects of an object that change over time (state diagram)
Interaction model
Objects in a system cooperate to achieve broader results
(Use case/sequence/activity diagram)
2006-04-12 5/23
KAIST
Software Engineering LAB
Object and class concepts (1/4)
Object
Concept, abstraction, or thing with identity
Proper nouns or specific reference in problem
description
Class
Group of objects with
Same properties (attributes)
Behavior (operations)
Kinds of relationships
Semantics
2006-04-12 6/23
KAIST
Software Engineering LAB
Object and class concepts (2/4)
Class diagrams
Graphic notation for modeling classes and their
relationships
Object diagrams
Graphic notation for individual objects and their
relationships
Rookie :Rookie TaeHoon:Rookie SeokJoong:Rookie
Class Objects
2006-04-12 7/23
KAIST
Software Engineering LAB
Object and class concepts (3/4)
Value : piece of data
Attribute : value for each object
Operation
Function or procedure that may be applied to or by
objects in a class
All objects in a class share the same operations
Class
Rookie
name:string
birthdate:date
enroll
( types )
TaeHoon:Rookie
name=Tae Hoon
birthdate=6 Dec 1975
( attributes )
( operation )
Object
( values )
2006-04-12 8/23
KAIST
Software Engineering LAB
Object and class concepts (4/4)
Summary of notation for class
ClassName
attributeName1 : dataType1 = defaultValue1
attributeName2 : dataType2 = defaultValue2

operationName1 ( argumentList1 ) : resultType1


operationName2 ( argumentList2 ) : resultType2

2006-04-12 9/23
KAIST
Software Engineering LAB
Link and association concepts (1/8)
Links and associations
Link
Physical or conceptual connection among objects
Instance of an association
Association
Group of links with common structure and common
semantics
Set of potential links
Links and associations
: Verb in problem statements
2006-04-12 10/23
KAIST
Software Engineering LAB
Link and association concepts (2/8)
Links and associations (Contd)
* *
Rookie
name
Company
name
Class diagram
Hoon:Rookie
name=Hoon
OwnStock
Joong:Rookie
name=Joong
Seok:Rookie
name=Seok
MS:Company
name=MS
SUN:Company
name=SUN
Object diagram
(Association name)
(Association)
(Link)
2006-04-12 11/23
KAIST
Software Engineering LAB
Link and association concepts (3/8)
Multiplicity
Constrain the number of related objects
Assign a multiplicity to an association end
Husband
name
Wife
name
Class diagram
HasWife
1 1
Seok:Husband
name=Seok
Hee:Wife
name=Hee
Hoon:Husband
name=Hoon
Lyn:Wife
name=Lyn
Object diagram
(Multiplicity)
2006-04-12 12/23
KAIST
Software Engineering LAB
Link and association concepts (4/8)
Association end names
Each end of an association can have a name
Convenience for traversing associations
Person Company
employee
WoksFor
0..1
*
employer
(Association end names)
employee
Taehoon
Seokjoong
Youngseok
employer
MS
MS
IBM
2006-04-12 13/23
KAIST
Software Engineering LAB
Link and association concepts (5/8)
Ordering
Indicate an ordered set of objects
Provide an explicit order
Permitted only for binary associations
Screen Window
VisibleOn
*
1
{ordered}
2006-04-12 14/23
KAIST
Software Engineering LAB
Link and association concepts (6/8)
Bags and Sequences
Permit multiple links for a pair of objects
Bag
Collection of elements with duplicates allowed
Sequence
Ordered bag
Permitted only for binary associations
Itinerary Airport
*
*
{sequence}
2006-04-12 15/23
KAIST
Software Engineering LAB
Link and association concepts (7/8)
Association classes
Derive identity from instances of the constituent
classes
Have attributes and operations
Participate in associations
User Workstation
*
*
Authorization
priority
startSession
(Association class)
(Dash line)
Workstation
*
1
home
(Participating in an
association)
2006-04-12 16/23
KAIST
Software Engineering LAB
Link and association concepts (8/8)
Qualified Associations
Disambiguate the objects for a many association
end
Select among the target objects, reducing the
effective multiplicity, from many to one
(Qualified)
Bank Account
0..1
accountNumber
1
(Not qualified)
Bank
*
Account
1
accountNumber
(Qualifier)
2006-04-12 17/23
KAIST
Software Engineering LAB
Generalization and inheritance (1/3)
Definition
Generalization
Relationship between a class (the superclass) and one
or more variations of the class (the subclass)
Inheritance
Each subclass has the features of its superclass
Use of generalization
Support for polymorphism
Structure the description of objects
Enable reuse of code
2006-04-12 18/23
KAIST
Software Engineering LAB
Generalization and inheritance (2/3)
Overriding features
Refines and replaces
(Subclass feature superclassfeature)
To specify behavior that depends on the subclass
To tighten the specification of a feature
To improve performance
2006-04-12 19/23
KAIST
Software Engineering LAB
Generalization and inheritance (3/3)
Tank
gun
cannon
fire
move
Truck
box
bos
bring
Crane
jack
bos
lift
Vehicle
engine
door
wheel
displacement
move
(Generalization)
(Overriding Feature)
2006-04-12 20/23
KAIST
Software Engineering LAB
Navigation of class models (1/3)
Navigation
Express the behavior of navigating among classes
Exercise a model and uncover hidden flaws and
omissions
Traverse the constructs in class models with OCL
Object Constraint Language (OCL)
Attributes
Traverse from an object to an attribute value
Vehicle . displacement
2006-04-12 21/23
KAIST
Software Engineering LAB
Navigation of class models (2/3)
Object Constraint Language (OCL) (Contd)
Operations
Invoke an operation for an object
Tank . Fire
Operate on entire collections
Vehicle . Tank . gun -> sum ( )
Simple association
Traverse an association to a target end
Person . employee
Qualified association
Make a more precise traversal
Bank . accountNumber [060411]
2006-04-12 22/23
KAIST
Software Engineering LAB
Navigation of class models (3/3)
Object Constraint Language (OCL) (Contd)
Association class
Find the constituent objects or the multiple links of an
association class
Generalization
Traverse a generation hierarchy
Filters
Filter the objects in a set
Vehicle . displacement -> select ( amount > cc 2000 )
2006-04-12 23/23
KAIST
Software Engineering LAB
Summary
Class model
Static data structure of objects and their
relationships to one another
Concepts
Object : concept, abstraction, identified thing
Class : group of objects (attribute, behavior, relations)
Link and association : set of potential links
Generalization : relationship between the superclassand
the subclasses
Navigation of class model : behavior of navigation among
classes
2006-04-12 24/23
KAIST
Software Engineering LAB
The end
The end
Thank you
Thank you