Professional Documents
Culture Documents
UML - Class Diagram
UML - Class Diagram
OO
AD OBJECT-ORIENTED ANALYSIS AND DESIGN 1
OO
AD
PLAN
Class diagram
Relationships
OBJECT-ORIENTED ANALYSIS AND DESIGN
2
OO
AD
What is a Class Diagram?
3
OO
AD
Objects
4
OO
AD
Class
MovieClubMember
Class attributes
operations
Objects
5
OO
AD
Class notation in class diagram
Class name
OBJECT-ORIENTED ANALYSIS AND DESIGN
private
Attributes
protected
public Methods
6
OO
AD
Generalization relationship
Student Person
7
OO
AD
Generalization relationship
Student Employee
TeachingAssistant
8
OO
AD
Generalization relationship
Abstract class
OBJECT-ORIENTED ANALYSIS AND DESIGN
Shape
draw()
Circle Rectangle
draw() draw()
9
OO
AD
Generalization relationship
Discriminator
Discriminator
OBJECT-ORIENTED ANALYSIS AND DESIGN
Doctor
Female
role
Person Nurse
Gender
Male {complete}
patient
Physical-
therapist
Patient
10
OO
AD
Associations relationship
11
OO
AD
Associations relationship
Properties
o Name
OBJECT-ORIENTED ANALYSIS AND DESIGN
o Role
› The specific role of the association
o Multiplicity
› Indicates the number of objects that are connected
o Type
› Plain association, aggregation, composition
o Direction
12
OO
AD
Associations
Role
employee employer
Person Company
works for
Association Name
13
OO
AD
Associations
classes.
Association name
Class1 Class2
multiplicity multiplicity
Multiplicity notation
o* 0, 1, or more
o5 5 exactly
o 5..8 between 5 and 8, inclusive
o 5..* 5 or more
14
OO
AD
Associations
Multiplicity example
o A Student can take up to 5 Courses.
OBJECT-ORIENTED ANALYSIS AND DESIGN
Student Course
10..300 takes 1..5
15
OO
AD
Associations
Multiplicity example
o A teacher teaches 1 to 3 courses (subjects)
OBJECT-ORIENTED ANALYSIS AND DESIGN
1 teaches 1..3
Teacher Course
1..5
takes
Students
10..300
16
OO
AD
Self association
1
Employee
manager
Responsible for worker
0..10
17
OO
AD
Multi associations
Captain
Team
Member 1 0..1
Player Team
10
11 member of 1
Captain
1
Leads
18
OO
AD
Aggregation
Engine
Car
Transmission
19
OO
AD
Composition
Can they be aggregation?
Special Aggregation
Strong ownership
OBJECT-ORIENTED ANALYSIS AND DESIGN
Scrollbar
Window Titlebar
Menu
20
OO
AD
How to identify aggregation / composition?
21
OO
AD
Why aggregation / composition?
parts
Identifying whole - parts supports encapsulation
22
OO
AD
Dependency
class.
Always directed
Caused by class methods
o local variable, parameter, return value
Circle
Point
Move(p:Point)
23
OO
AD
Dependency
circleA:Circle
Circle
circleB:Circle
24
OO
AD
Realization (implementation)
interface or protocol).
An interface can be realized by many classes.
A class may realize many interfaces.
25
OO
AD
Realization
Example
OBJECT-ORIENTED ANALYSIS AND DESIGN
Keyboard
brandName <<interface>>
numOfKeys TypeWriter
ctl()
pageDown() keyStroke()
26
OO
AD
Constraint rules and Notes
Customer 1 * may be
Order
{ total < $50 } canceled
id: long { value > 0 }
Constraint Note
27
OO
AD
Common mistakes / confusions
28
OO
AD
From user requirements to Class Diagram
them”
29
OO
AD
User requirements …
Zounds international (Audiovisual sales) Has A number of
(sub) divisions such as Purchasing, NetSales, Stock, Retail
OBJECT-ORIENTED ANALYSIS AND DESIGN
etc. ‘Retail’ has outlets (e.g. in Malls and High street stores).
NetSales has both ‘Hard’ (CDs, DVDs…) and ‘soft’
(downloads) sales. Retail and Netsales co-operate to
produce ‘Personal mixes’ that they burn onto CDs to
produce items for individual customers. Customers may
open an account to facilitate the payment for multiple
transactions or they may just buy goods in individual
purchases paying by cash, cheque or card. The staff selling
the good are recorded.
30
OO
AD
User requirements …
Zounds international (Audiovisual sales) Has A number of
(sub) divisions such as Purchasing, NetSales, Stock, Retail
OBJECT-ORIENTED ANALYSIS AND DESIGN
etc. ‘Retail’ has outlets (e.g. in Malls and High street stores).
NetSales has both ‘Hard’ (CDs, DVDs…) and ‘soft’
(downloads) sales. Retail and Netsales co-operate to
produce ‘Personal mixes’ that they burn onto CDs to
produce items for individual customers. Customers may
open an account to facilitate the payment for multiple
transactions or they may just buy goods in individual
purchases paying by cash, cheque or card. The staff selling
the good are recorded.
31
OO
AD
User requirements …
• Transactions
• Purchases • Cheque
• Cash
• Card
34
OBJECT-ORIENTED ANALYSIS AND DESIGN
AD
OO
Classes
35
OO
AD
User requirements …
The divisions and subdivisions each have a single manager and may
have staff. Staff are employed by Zounds international and are
OBJECT-ORIENTED ANALYSIS AND DESIGN
assigned to exactly one division. There are many types of staff and
their assignment/role (Cleaner, NetSales, Manager) may vary during
their time with ZI. All subdivisions have only one parent division but
parent divisions may have many subdivisions. Theoretically all the
parent divisions have control over all their subdivisions, though in
practice this is seldom enforced for the mundane ‘day-to-day’
running of the company. All Sub-divisions are cost centres,
maintaining their own accounts but constrained to follow a
centralised accounting model with a standard way of maintaining
the balance and transaction history and recording transactions.
36
OO
AD
User requirements …
The divisions and subdivisions each have a single manager and may
have staff. Staff are employed by Zounds international and are
OBJECT-ORIENTED ANALYSIS AND DESIGN
assigned to exactly one division. There are many types of staff and
their assignment/role (Cleaner, NetSales, Manager) may vary during
their time with ZI. All subdivisions have only one parent division but
parent divisions may have many subdivisions. Theoretically all the
parent divisions have control over all their subdivisions, though in
practice this is seldom enforced for the mundane ‘day-to-day’
running of the company. All Sub-divisions are cost centres,
maintaining their own accounts but constrained to follow a
centralised accounting model with a standard way of maintaining
the balance and transaction history and recording transactions.
37
OO
AD
OBJECT-ORIENTED ANALYSIS AND DESIGN Classes and relationships
38
OO
AD
Hidden objects/classes
Web pages
Windows Remember class UITool?
OBJECT-ORIENTED ANALYSIS AND DESIGN
Dialogs
“Data Access” Classes
…
39
OO
AD
Exercise
The ABC bookstore offers a Web system that allows its customers to
search, reserve, buy and rent books online. Any customer can visit the
bookstore’s official Web site to search for book details, but only the
OBJECT-ORIENTED ANALYSIS AND DESIGN
Draw class diagram (use CRC first). Make your own assumptions if needed 41