ch3 class modeling
TRANSCRIPT
-
8/12/2019 CH3 Class Modeling
1/24
Software Engineering Lab
2006-04-12
1
SE LAB
KAIST
Tae-Hoon Song
CH3. Class Modeling
Michael Blaha, James RumbaughObject-Oriented Modeling and Design with UML
-
8/12/2019 CH3 Class Modeling
2/24
2006-04-12 2/23
KAIST
Software Engineering LAB
Contents
Introduction
Background Object and class concepts
Link and association conceptsGeneralization and inheritance
Navigation of class modelsSummary
-
8/12/2019 CH3 Class Modeling
3/24
2006-04-12 3/23
KAIST
Software Engineering LAB
Introduction
Object-oriented modeling and design
Way of thinking about problems using modelsorganized around real-world concepts
Class modelingDescribe the static data of objects and theirrelationships to one another
Define each conceptPresent the corresponding UML notation
-
8/12/2019 CH3 Class Modeling
4/242006-04-12 4/23
KAIST
Software Engineering LAB
Background
Model
Abstraction of something for purpose ofunderstanding it before building itViewpoints
Class modelStructure of objects in a system (class diagram)
State modelAspects of an object that change over time (state diagram)
Interaction modelObjects in a system cooperate to achieve broader results(Use case/sequence/activity diagram)
-
8/12/2019 CH3 Class Modeling
5/242006-04-12 5/23
KAIST
Software Engineering LAB
Object and class concepts (1/4)
Object
Concept, abstraction, or thing with identityProper nouns or specific reference in problemdescription
ClassGroup of objects with
Same properties (attributes)Behavior (operations)Kinds of relationshipsSemantics
-
8/12/2019 CH3 Class Modeling
6/242006-04-12 6/23
KAIST
Software Engineering LAB
Object and class concepts (2/4)
Class diagrams
Graphic notation for modeling classes and theirrelationships
Object diagramsGraphic notation for individual objects and theirrelationships
Rookie :RookieTaeHoon :Rookie SeokJoong :Rookie
lass Objects
-
8/12/2019 CH3 Class Modeling
7/242006-04-12 7/23
KAIST
Software Engineering LAB
Object and class concepts (3/4)
Value : piece of data
Attribute : value for each objectOperation
Function or procedure that may be applied to or byobjects in a classAll objects in a class share the same operations
lass
Rookiename :string
birthdate :date
enroll
( types ) TaeHoon:Rookiename=Tae Hoonbirthdate =6 Dec 1975
( attributes )
( operation )
Object
( values )
-
8/12/2019 CH3 Class Modeling
8/242006-04-12 8/23
KAIST
Software Engineering LAB
Object and class concepts (4/4)
Summary of notation for class
ClassNameattributeName1 : dataType1 = defaultValue1
attributeName2 : dataType2 = defaultValue2
operationName1 ( argumentList1 ) : resultType1
operationName2 ( argumentList2 ) : resultType2
-
8/12/2019 CH3 Class Modeling
9/24
2006-04-12 9/23
KAIST
Software Engineering LAB
Link and association concepts (1/8)
Links and associations
Link Physical or conceptual connection among objectsInstance of an association
AssociationGroup of links with common structure and commonsemanticsSet of potential links
Links and associations
: Verb in problem statements
-
8/12/2019 CH3 Class Modeling
10/24
2006-04-12 10/23
KAIST
Software Engineering LAB
Link and association concepts (2/8)
Links and associations (Contd)
* *RookienameCompany
name lass diagram
Hoon:Rookiename=Hoon
OwnStock
Joong:Rookiename=Joong
Seok:Rookiename=Seok
MS:Companyname=MS
SUN:Companyname=SUN
Object diagram
( Association name )
( Association )
(Link)
-
8/12/2019 CH3 Class Modeling
11/24
2006-04-12 11/23
KAIST
Software Engineering LAB
Link and association concepts (3/8)
Multiplicity
Constrain the number of related objectsAssign a multiplicity to an association end
Husbandname
Wifename
lass diagramHasWife
1 1
Seok:Husbandname=Seok
Hee:Wifename=Hee
Hoon:Husbandname=Hoon
Lyn:Wifename=Lyn
Object diagram
(Multiplicity )
KAIST
-
8/12/2019 CH3 Class Modeling
12/24
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 nameConvenience for traversing associations
Person CompanymployeeWoksFor 0..1*
employer( Association end names )
employeeTaehoonSeokjoongYoungseok
employerMSMS
IBM
KAIST
-
8/12/2019 CH3 Class Modeling
13/24
2006-04-12 13/23
KAIST
Software Engineering LAB
Link and association concepts (5/8)
Ordering
Indicate an ordered set of objectsProvide an explicit order
Permitted only for binary associations
Screen WindowVisibleOn 1
{ordered}
KAIST
-
8/12/2019 CH3 Class Modeling
14/24
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 objectsBag
Collection of elements with duplicates allowed
SequenceOrdered bag
Permitted only for binary associations
Itinerary Airport
{sequence}
KAIST
-
8/12/2019 CH3 Class Modeling
15/24
2006-04-12 15/23
KAIST
Software Engineering LAB
Link and association concepts (7/8)
Association classes
Derive identity from instances of the constituentclassesHave attributes and operationsParticipate in associations
User Workstation
Authorizationpriority
startSession
( Association class )
(Dash line )
Workstation 1home
(Participating in anassociation )
KAIST
-
8/12/2019 CH3 Class Modeling
16/24
2006-04-12 16/23
KAIST
Software Engineering LAB
Link and association concepts (8/8)
Qualified Associations
Disambiguate the objects for a many associationend Select among the target objects, reducing theeffective multiplicity, from many to one
(Qualified )
Bank Account..1accountNumber 1
(Not qualified )Bank
Account
accountNumber
(Qualifier )
KAIST
-
8/12/2019 CH3 Class Modeling
17/24
2006-04-12 17/23
KAIST
Software Engineering LAB
Generalization and inheritance (1/3)
Definition
GeneralizationRelationship between a class (the superclass ) and oneor more variations of the class (the subclass )
InheritanceEach subclass has the features of its superclassUse of generalization
Support for polymorphismStructure the description of objects
Enable reuse of code
KAIST
-
8/12/2019 CH3 Class Modeling
18/24
2006-04-12 18/23
Software Engineering LAB
Generalization and inheritance (2/3)
Overriding features
Refines and replaces(Subclass feature superclass feature)
To specify behavior that depends on the subclassTo tighten the specification of a featureTo improve performance
KAIST
-
8/12/2019 CH3 Class Modeling
19/24
2006-04-12 19/23
Software Engineering LAB
Generalization and inheritance (3/3)
Tankguncannonfiremove
Truckboxbosbring
Crane jackboslift
Vehicleengine
door wheeldisplacementmove
(Generalization )
(Overriding Feature )
KAIST
-
8/12/2019 CH3 Class Modeling
20/24
2006-04-12 20/23
Software Engineering LAB
Navigation of class models (1/3)
Navigation
Express the behavior of navigating among classesExercise a model and uncover hidden flaws andomissions
Traverse the constructs in class models with OCLObject Constraint Language (OCL)
AttributesTraverse from an object to an attribute value
Vehicle . displacement
KAIST
-
8/12/2019 CH3 Class Modeling
21/24
2006-04-12 21/23
Software Engineering LAB
Navigation of class models (2/3)
Object Constraint Language (OCL) (Contd)
OperationsInvoke an operation for an objectTank . Fire
Operate on entire collectionsVehicle . Tank . gun -> sum ( )
Simple associationTraverse an association to a target end
Person . employee
Qualified associationMake a more precise traversal
Bank . accountNumber [060411]
KAIST
-
8/12/2019 CH3 Class Modeling
22/24
2006-04-12 22/23
Software Engineering LAB
Navigation of class models (3/3)
Object Constraint Language (OCL) (Contd)
Association classFind the constituent objects or the multiple links of anassociation class
GeneralizationTraverse a generation hierarchy
FiltersFilter the objects in a set
Vehicle . displacement -> select ( amount > cc 2000 )
KAIST
-
8/12/2019 CH3 Class Modeling
23/24
2006-04-12 23/23
Software Engineering LAB
Summary
Class model
Static data structure of objects and theirrelationships to one another
ConceptsObject : concept, abstraction, identified thingClass : group of objects (attribute, behavior, relations)
Link and association : set of potential linksGeneralization : relationship between the superclass andthe subclasses
Navigation of class model : behavior of navigation amongclasses
KAIST
-
8/12/2019 CH3 Class Modeling
24/24
2006-04-12 24/23
Software Engineering LAB
The endThe end
Thank youThank you