Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1
A Simplified Object-Oriented
Systems Analysis & Conceptual Design Methodology
Activities
1.Identify the information system’s purpose
2
Objects
3
Defining Class
A CLASS is a template (specification, blueprint)
for a collection of objects that share a common
set of attributes and operations.
HealthClubMember
Class attributes
operations
Objects
4
•Relationships
A RELATIONSHIP is what a class or an object
knows about another class or object.
In this example:
•Removal of a University
Course should also
UniversityCourse remove Students that are
in the Course but not
Student Information.
•
StudentInformation 1 •Removal of a Student
should also remove the
Courses that the Student
0,m is in but not the University
Course.
1 StudentInCourse •
•Removal of a Student in a
0,m Course should not affect
either University Course or
Student Information.
6
UML Class Diagram Notation 1 of 2
Class
{
Member
memberNumber Expanded view of a
firstName
lastName Class into its three
attributes telephone sections:
address
city Top: Class Name
etc... Middle: attributes
{
checkOutVideo Bottom: operations
operations checkInVideo
buyItem
etc...
7
UML Class Diagram Notation 2 of 2
Class
Generalization
Relationship
Object Object
Aggregation Composition
Object Association Association Association
n n 1..* 1
0..* 0..*
• Generalization
■ Object
• Association
• Aggregation
• Composition
9
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
■ 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.
■ Inherited operations in the specialization classes may be
polymorphic.
■ Only use when objects do NOT “transmute” (add, copy, delete)
■ Multiple inheritance is allowed in the UML but can complicate the
class model’s understanding and implementation (e.g., C++
supports but Java and Smalltalk do not).
10
Generalization Example
Others:
<<abstract>> •Transactions
Role •Things
attributes •Places
operations •Etc...
Person
attributes
operations
12
Generalization Inheritance Generalization
a1
a2
Generalization a3
a1 o1
a2 o2
a3 One-Way
Common o3
o1 Inheritance
o2 from the
o3 Generalization Specialization
to the a1
Specialization a2
a3
Specialization a4
a4 a5
a5 a6
a6
Unique o1
o4 o2
o5 o3
o6 o4
o5
(a = attribute; o = operation) o6
13
Generalization - Multiple Inheritance
Generalization1 Generalization2
a1 a2
a2 a4
a3 a5
o3 o1
o4 o2
o5 o3
Specialization
a6
a7 a1
a8 a2 (which one?)
inherited attributes a3
a4
o6
o1 a5
o7
o2 o8
(which one?) o3 inherited operations
o4
o5
14
UML Generalization Notation
Note
Useful text
Supertype
discriminator
Subtype 1 Subtype 2
Discriminator
Doctor
Female
role
<<abstract
>> Nurse
Gender Person
Male {complete} patient
Physical-
#1 therapist
Patient
#3
#2 16
Rational Rose Class Diagram Example
17
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
18
Object Association Relationship Patterns
b) Object Whole
attributes
Aggregation operations
Associations
Class A x x
attributes x
operations
x x x x
c) Object Whole
attributes
Composition operations
Class A x Class B Associations
attributes attributes (y may not be “1”) 1 1
operations x operations 1
y y y
a) Object Associations
Part1 Part2 PartN
attributes attributes attributes
operations operations operations
19
Associations
role B
Class A Class B
role A
Example:
Employee
Company Person
Employer
20
Multiplicities
1
Class exactly one
0..* many
Class (zero or more)
0..1 optional
Class (zero or one)
m..n numerically
Class specified
Example:
0..*
CourseOfferin
Course
1 g
21
Aggregation & Composition
•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???
22
Aggregation Composition
Faculty SalesOrder
(team-teaching 1..* 1
is possible)
0..* 1..*
CourseTeaching SalesOrderLineItem
FacultyStudent
Template/Pattern Example
w
Whole 1 w
Whole 2 w
3 w
4
0..*
p
p 6
0..* p 5
p 4
p
Part p 2 3
Part 1
25
Multiplicity Example #1
Whole
3
1
5 2
Part1 PartN
26
Multiplicity Example #2
Class1
max. 1 2..5
min.
1..n
0..*
Class2 Class3
1..n * 2..5 C1
C2 1 C1 C3
C3
C1
C2 C3 C1
C2 C2 C1 C3
C1 C1
C3
C2 C1
C2 C3
etc... etc...
27
Multiplicity Example #3
FacultyInformation StudentInformation
1 0..* 1 1 1
1..* 0..*
0..*
DegreeHeld CommitteeAssign
CourseCompleted
0..* 0..*
CourseTeach ClubMember
28
“many-to-many” multiplicity
StudentInformation CourseInformation
0..*
attributes attributes
operations 0..* operations
Becomes either
1 1
0..* 0..*
Course
0..*
is pre-requisite for
0..*
has pre-requisite of
30
Video Store – UML Class Diagram
1 1
Inventory
SaleItem RentalItem
0..* 0..*
Transaction Employee StoreLocation
1 1
35