conceptual design: uml class diagram relationships 1
TRANSCRIPT
![Page 1: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/1.jpg)
CONCEPTUAL DESIGN:
UML CLASS DIAGRAM
RELATIONSHIPS
1
![Page 2: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/2.jpg)
What is UML?
A standardized, graphical “modeling language” for communicating software design.
Allows implementation-independent specification of:user/system interactions (required behaviors)partitioning of responsibility (OO)integration with larger or existing systemsdata flow and dependencyoperation orderings (algorithms)concurrent operations
Pretty pictures.UML is not “process”. (That is, it doesn’t tell you how to do
things, only what you should do.)
2
![Page 3: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/3.jpg)
Motivations for UML
• UML is a fusion of ideas from several precursor modeling languages.
• We need a modeling language to:– help develop efficient, effective and correct
designs, particularly Object Oriented designs.– communicate clearly with project stakeholders
(concerned parties: developers, customer, etc).– give us the “big picture” view of the project.
3
![Page 4: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/4.jpg)
Types of UML diagrams
• There are different types of UML diagram, each with slightly different syntax rules:– use cases.– class diagrams.– sequence diagrams.– package diagrams.– state diagrams– activity diagrams– deployment diagrams.
4
![Page 5: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/5.jpg)
1. Identify the information system’s purpose
2. Identify the information system’s actors and features
3. Identify Use Cases and create a Use Case Diagram
4. Identify Objects and their Classes and create a Class Diagram
5. Create Interaction/Scenario Diagrams
6. Create Detail Logic for Operations
7. Repeat activities 1-6 as required to refine the “blueprints”
A Simplified Object-OrientedSystems Analysis & Conceptual Design Methodology
Activities
5
![Page 6: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/6.jpg)
• Objects have three responsibilities:
What they know about themselves – (e.g., Attributes)
What they do – (e.g., Operations)
What they know about other objects – (e.g., Relationships)
Objects
6
![Page 7: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/7.jpg)
Defining ClassA CLASS is a template (specification, blueprint)for a collection of objects that share a commonset of attributes and operations.
HealthClubMember
Class
Objects
attributesoperations
7
![Page 8: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/8.jpg)
• RelationshipsA RELATIONSHIP is what a class or an object knows about another
class or object.
Generalization (Class-to-Class) (Superclass/Subclass)• Inheritance• Ex: Person - FacultyPerson, StudentPerson, Staff...• Ex: ModesOfTravel - Airplane, Train, Auto, Cycle, Boat...
[Object] Associations• FacultyInformation - CourseInformation• StudentInformation - CourseInformation
[Object] Aggregations & Composition (Whole-Part)• Assembly - Parts• Group - Members• Container - Contents
F o
u r
T y
p e
s
8
![Page 9: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/9.jpg)
• Relationships
1) show relationships 2) enforce integrity 3) help produce results
• Removal of a University Course should also remove Students that are in the Course but not Student Information.
• Removal of a Student should also remove the Courses that the Student is in but not the University Course.
• Removal of a Student in a Course should not affect either University Course or Student Information.
1
0,m
UniversityCourse
StudentInCourse
StudentInformation
1
0,m
Exist to:
In this example:
9
![Page 10: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/10.jpg)
UML Class Diagram Notation
MembermemberNumberfirstNamelastNametelephoneaddresscityetc...
checkOutVideocheckInVideobuyItemetc...
attributes
operations
{{
Expanded view of a
Class into its three
sections:
Top: Class Name
Middle: attributes
Bottom: operations
Class
1 of 2
10
![Page 11: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/11.jpg)
Object Association
n n
ClassGeneralizationRelationship
ObjectAggregationAssociation
0..*
1..*
Object CompositionAssociation
0..*
1
UML Class Diagram Notation 2 of 2
Will always be “1”11
![Page 12: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/12.jpg)
Class Diagram Relationships
Class
Generalization
Object
Association
Aggregation
Composition
12
![Page 13: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/13.jpg)
Generalization (Class-to-Class) (superclass – subclass; supertype – subtype)
A Generalization follows a “is a” or “is a kind of” heuristic from a specialization class to the generalization class. (e.g., student “is a” person, video “is a kind of” inventory).
Common attributes, operations and relationships are located in the generalization class and are inherited by the specialization classes
13
![Page 14: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/14.jpg)
• Unique attributes, operations and relationships are located in the specialization classes.
• Inherited attributes and operations may be overridden or enhanced in the specialization class depending on programming language support.
14
![Page 15: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/15.jpg)
<<abstract>>Role
attributes
operations
Generalization Example
Faculty
attributes
operations
Student
attributes
operations
Staff
attributes
operations
Visitor
attributes
operations
Note: <<abstract>> = no objects
Others:• Transactions• Things• Places• Etc...
15
![Page 16: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/16.jpg)
Person
attributes
operations
Poor Generalization Example(violates the “is a” or “is a kind of” heuristic)
Arm
attributes
operations
Leg
attributes
operations
Head
attributes
operations
16
![Page 17: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/17.jpg)
Generalization Inheritance
Generalization
a1a2a3o1o2o3
Specialization
a4a5a6o4o5o6
One-WayInheritance
from theGeneralization
to theSpecialization
Specialization
a1a2a3a4a5a6o1o2o3o4o5o6(a = attribute; o = operation)
Common
Unique
Generalization
a1a2a3o1o2o3
17
![Page 18: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/18.jpg)
Generalization - Multiple Inheritance
Generalization1
a1a2a3
o3o4o5
Specialization
a6a7a8
o6o7o8
Generalization2
a2a4a5
o1o2o3
inherited attributes
a1a2 (which one?)a3a4a5
inherited operations
o1o2o3o4o5
(which one?)
18
![Page 19: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/19.jpg)
UML Generalization Notation
Supertype
Subtype 2Subtype 1
discriminator
Useful text
Note
Note: Supertype = Superclass; Subtype = Subclass19
![Page 20: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/20.jpg)
Generalization - Multiple Classification
<<abstract>>Person
Female
Male
Physical-therapist
Nurse
Doctor
role
Patient
patient
Gender{complete}
Discriminator
#1
#2
#3
20
![Page 21: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/21.jpg)
Associations
Relationships between instances (objects) of classes
Conceptual:• associations can have two roles (bi-directional):
– source --> target– target --> source
• roles have multiplicity (e.g., cardinality, constraints)• To restrict navigation to one direction only, an arrowhead is used to
indicate the navigation direction
No inheritance as in generalizations
21
![Page 22: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/22.jpg)
x
x
x
x
x
x
Wholeattributesoperations
PartNattributesoperations
Part2attributesoperations
Part1attributesoperations
1
y
1
y
1
y
Wholeattributesoperations
PartNattributesoperations
Part2attributesoperations
Part1attributesoperations
Class Aattributesoperations
Class Battributesoperations
Class Aattributesoperations
Class Battributesoperations
x
x
x
x
Object Association Relationship Patterns
a) Object Associations
b) ObjectAggregationAssociations
c) ObjectCompositionAssociations(y may not be “1”)
22
![Page 23: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/23.jpg)
Associations
Class A Class Brole A
role B
Company PersonEmployer
Employee
Example:
23
![Page 24: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/24.jpg)
Multiplicities
Class
Class
Class
Class
1
0..*
0..1
m..n
exactly one
many(zero or more)
optional(zero or one)
numericallyspecified
Course CourseOffering1
0..*
Example:
24
![Page 25: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/25.jpg)
Aggregation & Composition
25
• Aggregation (shared aggregation):• is a specialized form of ASSOCIATION in which a whole is related to its
part(s).• is known as a “part of” or containment relationship and follows the “has
a” heuristic• three ways to think about aggregations:
• whole-parts• container-contents• group-members
• Composition (composite aggregation):• is a stronger version of AGGREGATION• the “part(s)” may belong to only ONE whole• the part(s) are usually expected to “live” and “die” with the whole
(“cascading delete”)• Aggregation vs. Composition vs. Association???
![Page 26: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/26.jpg)
Aggregation Composition
0..*
1..*
Faculty
CourseTeaching
1..*
1
SalesOrder
SalesOrderLineItem
(another: hand --> finger)(another: assembly --> part)
(team-teaching is possible)
26
![Page 27: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/27.jpg)
Association, Aggregation and Composition
Whole
Part
Whole
Part
0..*
0..*
w1 w
2 w3 w
4
p6
p4
p5
p3p
1
p2
Template/Pattern Example
(association, aggregation & composition look the same)
27
![Page 28: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/28.jpg)
Whole
51
2
3
Multiplicity Example #1
•One Whole is associated with 5 Part1•One Part1 is associated with 1 Whole
W
P
PPPP
WPW
PP WP
W
W
•One Whole is associated with 2 PartN•One PartN is associated with 3 Whole
Part1 PartN
28
![Page 29: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/29.jpg)
Multiplicity Example #2
1..n
1
0..*
2..5
C1
C2
C2C2C2C2
etc...
min.max.
C1
C3
C3C3C3C3
etc...
C3
C1
C1C1
C1C11..n * 2..5
Class1
Class2 Class3
C2
C11
29
![Page 30: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/30.jpg)
FacultyInformation
1
0..*
1 11
1..* 0..*
0..*
0..*
Multiplicity Example #3
StudentInformation
DegreeHeld CommitteeAssign
CourseTeach ClubMember
CourseCompleted
0..*
30
![Page 31: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/31.jpg)
CourseInformation0..*
0..*
“many-to-many” multiplicity
attributesoperations
StudentInformation
attributesoperations
Becomes either
0..* 0..*
SemesterTakenGradeEarned
1 1
StudentInformation
attributesoperations
CourseInformation
attributesoperations
StudentCourseInformation
operations
Attributes that represent the “union” of the two classes are located in this “association” class.
StudentInformation
attributesoperations
CourseInformation
attributesoperations
0..*
0..*
SemesterTakenGradeEarned
StudentCourseInformation
operations
31
![Page 32: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/32.jpg)
Reflexive Association Relationships
Objects within the same class have arelationship with each other.
Course
0..*
0..*
has pre-requisite of
is pre-requisite for
32
![Page 33: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/33.jpg)
Inventory
Video Store – UML Class Diagram
SaleItem RentalItem
Video Game ConcessionItem VCR
Transaction Employee StoreLocation
SaleTransaction RentalTransaction Suplier
Member PurchaseOrder
SaleRentalLineItemPurchaseOrderLineItem
1
0..*
0..* 0..1 10..*
1..*
1 1
1..*
10..*
10..*
11..*
10..*
0..*
1
33
![Page 34: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/34.jpg)
34
![Page 35: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/35.jpg)
35
![Page 36: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/36.jpg)
36
![Page 37: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/37.jpg)
37
![Page 38: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/38.jpg)
38
![Page 39: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/39.jpg)
39
![Page 40: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/40.jpg)
40
![Page 41: CONCEPTUAL DESIGN: UML CLASS DIAGRAM RELATIONSHIPS 1](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649d205503460f949f55ec/html5/thumbnails/41.jpg)
41