Professional Documents
Culture Documents
UsingClassDiagrams
Dumitru Radoiu
DumitruRadoiu
Spring2009
PETRU MAIOR UNIVERSITY
Object-Oriented World
time
OO Analysis
Create the
vocabulary
Requirements
OO Design
Give
vocabulary
ocabu a y
behavior
(model the
system)
OO Programming
Program the
model
ode
Deliverables
Activity
UMLDiagram
Understand SystemUsage
UseCaseDiagram
Identify Classes
IdentifyClasses
DefineWorkflows
ActivityDiagram
Object-Oriented World
time
OO Design
OO Analysis
Create the
vocabulary
Requirements
Give
vocabulary
ocabu a y
behavior
(model the
system)
OO Programming
Program the
model
ode
A ti it
Activity
UML Di
UMLDiagram
Identifyinteractions
amongobjects
9
Sequenceand
CollaborationDiagrams
Analyzestatechanges
l
h
SateDiagrams
Refineclassdiagrams
ClassDiagrams
Deliverables
Agenda
WhyWeModelClassDiagrams
Why
We Model Class Diagrams
Notation
WhatMakesaClass
HowtoGiveAtributesDetail
HowtoGiveOperationsDetail
ModelaClassDiagram:CaseStudy
g
y
Mapping
Mapping
OO Design
OO Analysis
OO WORLD
Needs
Requirements
Data
Functionality
OO Programming
Mapping
OO Analysis
OO Design
OO Programming
Needs
Requirements
Technical entities
Agenda
WhyWeModelClassDiagrams
Why
We Model Class Diagrams
Notation
WhatMakesaClass
HowtoGiveAtributesDetail
HowtoGiveOperationsDetail
ModelaClassDiagram:CaseStudy
g
y
Notation
Name of the class
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
+ Eat()
+Sleep()
Sleep()
-Guardian
-Child
Lion
LittleBoy
1..*
1 2
1..2
Notation
Attributes ((data))
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
+ Eat()
+Sleep()
Sleep()
-Guardian
-Child
Lion
LittleBoy
1..*
1 2
1..2
Notation
Operations (behavior)
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
+ Eat()
+Sleep()
Sleep()
-Guardian
-Child
Lion
LittleBoy
1..*
1 2
1..2
Notation
Association
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
+ Eat()
+Sleep()
Sleep()
-Guardian
1 2
1..2
Guards>
-Child
Lion
LittleBoy
1..*
Notation
Association name
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
+ Eat()
+Sleep()
Sleep()
-Guardian
1 2
1..2
Guards>
-Child
Lion
LittleBoy
1..*
Notation
Multiplicity
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
+ Eat()
+Sleep()
Sleep()
-Guardian
-Child
Lion
LittleBoy
1..*
1 2
1..2
Notation
Rolename
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
+ Eat()
+Sleep()
Sleep()
-Guardian
-Child
Lion
LittleBoy
1..*
1 2
1..2
Notation
IInvisible
i ibl ffor access
for system classes
(private)
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
+ Eat()
+Sleep()
Sleep()
-Guardian
-Child
Lion
LittleBoy
1..*
1 2
1..2
Notation
Visible for access
for system classes
(public)
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
+ Eat()
+Sleep()
Sleep()
-Guardian
-Child
Lion
LittleBoy
1..*
1 2
1..2
Notation
Invisible for access
for classes outside
the system
(protected)
Animal
-Nr.OfEyes
y
- Nr.OfLegs
Parent
-Children
# Eat()
+Sleep()
Sleep()
-Guardian
-Child
Lion
LittleBoy
1..*
1 2
1..2
Notation
Public Interface
Cl
ClassName
N
- Attribute1
+ Attribute2
- operation1()
+ operation2()
- operation3()
By default invisible
By default visible
Agenda
WhyWeModelClassDiagrams
Why
We Model Class Diagrams
Notation
WhatMakesaClass
HowtoGiveAtributesDetail
HowtoGiveOperationsDetail
ModelaClassDiagram:CaseStudy
g
y
Cl
ClassName
N
-Attribute1
- Attribute2
+ operation1()
+ operation2()
Animal
Lion
Attributes and operations are hidden
Animal
+ Eat()
+Sleep()
Animal
+ Eat()
+Sleep()
C
Cannot
t ttellll if th
there are attributes
tt ib t iin th
the class
l
No attributes in the class
Animal
Animal
-Attribute1
- Attribute2
-Attribute1
- Attribute2
MathTeacher : Teacher
MathTeacher : Teacher
+TeacherName = George
- Password = georgepass
MathTeacher : Teacher
TeacherName
Password
MathTeacher : Teacher
+ ChangePassword()
+ RecordGrades()
+ ChangePassword()
+ RecordGrades()
+TeachClasses()
Packages
Grading :: Teacher
Package name
Agenda
WhyWeModelClassDiagrams
Why
We Model Class Diagrams
Notation
WhatMakesaClass
HowtoGiveAtributesDetail
HowtoGiveOperationsDetail
ModelaClassDiagram:CaseStudy
g
y
Student
+ Name : String
- Password : String
+ GradeLevel : Integer
Boolean
Double
Single
Byte
Integer
String
Currency
Long
Variant
Student
+ Name [1] : String = NewStudent
- Password [1] : String
+ GradeLevel [1] : Integer = 1
+ Grades [0..*] : Integer = {4,7,9,8}
Student
+ Name [1] : String = NewStudent
- Password [1] : String
+ GradeLevel [1] : Integer = 1
+ Grades [0..*] : Integer = {4,7,9,8}
+ / GPA [1] : Double = Null
Business logic is
included in a note
Student
+ Name [1] : String = NewStudent
- Password [1] : String
+ GradeLevel [1] : Integer = 1
+ Grades [0..*] : Integer
+ / GPA [1] : Double = Null
CurrentStudent : Student
+ Name [1] : String = NewStudent
- Password [1] : String
+ GradeLevel [1] : Integer = 1
+ Grades [0..*] : Integer = {4,7,9,8}
+ / GPA [1] : Double = 7.00
Agenda
WhyWeModelClassDiagrams
Why
We Model Class Diagrams
Notation
WhatMakesaClass
HowtoGiveAtributesDetail
HowtoGiveOperationsDetail
ModelaClassDiagram:CaseStudy
g
y
Student
+ Name [1] : String = NewStudent
- Password [1] : String
+ GradeLevel [1] : Integer = 1
+ Grades [0..*] : Integer
+ / GPA [1] : Double = Null
+ AddGrade(in Grade : Integer = 10)
+ ClearGrades()
+ ChangePassword(in OldPassowrd : String, in NewPassowrd : String) : Boolean
Operation
Parameter
name
Data type
Return value
Agenda
WhyWeModelClassDiagrams
Why
We Model Class Diagrams
Notation
WhatMakesaClass
HowtoGiveAtributesDetail
HowtoGiveOperationsDetail
ModelaClassDiagram:CaseStudy
g
y
<<include>>
save grades
Teacher
upgrade
pg
g
grades
<<include>>
<<include>>
load grades
logon
<<include>>
view
i
grades
d
Administrator
generate report
cards
Student
<<include>>
save grades
Teacher
upgrade
pg
g
grades
<<include>>
<<include>>
load grades
logon
<<include>>
view
i
grades
d
Administrator
generate
report cards
Student
<<include>>
save grades
Teacher
upgrade
pg
g
grades
<<include>>
<<include>>
load grades
logon
<<include>>
view
i
grades
d
Administrator
generate
report cards
Student
<<include>>
save grades
Teacher
upgrade
pg
g
grades
<<include>>
<<include>>
load grades
logon
? New class!!!
<<include>>
view
i
grades
d
Administrator
generate
report cards
Student
Teacher
Grades
ReportCard
WebSite
Dont forget the GUI
to transfer Actors
actions
Administrator
Student
Logon
g
Teacher
Grades
ReportCard
p
WebSite
Administrator
Student
Logon
g
maintains >
< contains
ReportCard
p
Grades
Teacher
^ displays
^ generates
WebSite
uses >
^ grants access to
Administrator
Logon
g
Student
uses >
< uses
maintains >
< contains
ReportCard
p
Grades
Teacher
^ displays
^ generates
WebSite
Change name to
OnlineUser uses >
^ grants access to
Administrator
Logon
g
Student
uses >
Little functionality;
y;
move it to WebSite
< uses
maintains >
< contains
Grades
Teacher
ReportCard
p
^ generates
^ displays
Administrator
uses >
Student
WebSite
maintains >
< contains
ReportCard
p
Grades
Teacher
1
1..*
1..*
1..*
^ generates
^ displays
1
Administrator
uses >
Student
WebSite
maintains >
< contains
ReportCard
p
Grades
Teacher
1
1..*
1..*
1..*
^ generates
^ displays
1
Administrator
uses >
Student
WebSite
+ Logon()
+ View()
maintains >
Grades
< contains
ReportCard
p
Teacher
1
1..*
1..*
+RecordGrades()
+UpgradeGrades()
+Distribute()
Di t ib t ()
-Save()
-Load()
1..*
^ generates
1
^ displays
Administrator
uses >
Student
WebSite
+ Logon()
+ View()