Documente Academic
Documente Profesional
Documente Cultură
Software engineering
UML diagrams
Unified Modelling Language (UML)
Visualise software system, code structure
Facilitates understanding of software system
Oval
Frame
SIZE: int
x,y: int
color: Color
paint()
MovableOval
deltaX, deltaY: int
paint()
Software engineering
move()
UML diagrams
UML diagrams
Use-case diagrams
Class diagrams
Association
Aggregation
Generalization
Instance diagrams
Interaction diagrams
Sequence diagram
Collaboration diagram
Software engineering
Use-case diagrams
A high level visualisation of how the system
System
Contains components used in a system
Represented by a labelled box
Banking system
Some actions
Some actions
Some actions
Software engineering
Actor
Who/what uses the system
Users of the system
Other components that interacts with the system
Exchanges information with system
Send/receive messages
Initiates/participates in use cases
A class, not an instance
Software engineering
Actor
Represented by a labelled stick figure, or a
class rectangle
<<Actor>>
Customer
OR
Customer
Person
Software engineering
Customer
Lecture Notes UML
Use cases
A set of sequence of actions performed by
components of a system
Initiated by an Actor
Connected to Actor by association
Represented by a labelled ellipse
A class, not an instance
Open
savings account
Software engineering
Use cases
Connected to Use cases by generalisation,
Validate user
<<include>>
Customer
Withdraw
cash
Software engineering
<<extend>>
Overdraft
Lecture Notes UML
10
Actor
Add course
Enter grade
for course
Student
Registrar
Get course info
Teacher
communication
Software engineering
11
Exercise
Identify possible objects from the use case
Software engineering
12
What to do next...
Identify the objects involved in each use
13
Identifying objects
Identify key attributes and functions from use
cases
Group closely related attributes
Group functions by data they act on
Person
name: String
address: String
age: int
addPerson()
Course
Staff
courseName: String
staffID: int
returnLecturers()
returnTimetable()
enterGrade()
findStudent()
Software engineering
Student
studentID: int
registerCourse()
14
Visibility
May wish to indicate the scope of
attributes/methods
Default visibility is public (+): can be used by outside
classes
Protected (#): can be used by descendents of the class
Private (-): can only be used within the class itself
Student
studentID: int
UPI: String
-Password: String
registerCourse()
#changePassword()
Software engineering
15
Object Relationships
Identified objects from use case diagram
Person
ClassName
name: String
address: String
age: int
Attributes
addPerson()
Operations
or, simplified
Person
16
Associations
Secretary *
Person
0,3..8
Company
Software engineering
Company
1..*
Manager
BoardOfDirectors
BoardOfDirectors
17
Associations
A more flexible representation of the relationship
between objects
A Bounce object uses a Movable object
Bounce
MovableOval
deltaX, deltaY: int
paint()
move()
Software engineering
borrows >
Book
18
Associations
Association name: verb/verb phrase (function-calls)
Role name: noun
Default: has (data)
Employee *
Secretary *
Office 0..1
Company
Software engineering
worksFor
Company
1..*
Manager
supervisor
allocatedTo >
* Employee
BoardOfDirectors
19
Directional associations
Given an Customer, want to be able to check
PIN
Software engineering
* LoginName
Password
20
Reflective associations
Used for specifying association between
interfaces
trainee:IEmployee
supervisor:IManager
Software engineering
Person
21
Exercises
Describe the associations represented by the
Booking
SpecificFlight
22
Inheritance
is-a relationship
MovableOval is an Oval
Connects a subclass to its
superclass
Superclass contains
attributes/methods common to all
its subclasses
Subclass contains
attributes/methods that are
different to its superclass
Software engineering
Oval
SIZE: int
x,y: int
color: Color
paint()
MovableOval
deltaX, deltaY: int
move()
23
Generalisation
Shows inheritance of classes
Represented by arrows towards the superclass
Generalise classes with common attributes,
24
Generalisation Example
Refer to the Bank example
Customer->Person
customer is a person
customer inherits person data/functions
Staff->Person
staff is a person
staff inherits person data/functions
Might also have Teller/Manager->Staff etc.
Avoid over generalisation
Software engineering
25
Generalisation Example
Person
Staff
name: String
address: String
age: int
staffID: int
addStaff()
findStaff()
returnDetails()
Teller
Customer
counterNumber:int
accountNumber: int
creditLimit: double
withdrawCashCounter()
acceptCheque()
Software engineering
withdrawCashATM()
checkBalanceATM()
26
Whole-Part
has-a relationship
Aggregation
A Car has 4 Wheels
Car
Wheel
Composition
A Building has a Room
Building
Software engineering
Room
27
Aggregation
Whole-part relationship between objects
Can be simplified by using associations,
isPartOf, or hasParts
Represented by
and
for composition (strong
aggregation)
Software engineering
28
Aggregation
Parts are part of the Aggregate
Aggregate is composed of Parts
Vehicle
* VehicleParts
Country
* Region
aggregate is destroyed
Building
Software engineering
* Room
29
Aggregation
One-to-one aggregation often corresponds
to attributes
Employee
Addresss
street
suburb
city
country
postCode
Software engineering
Employee
address: Address
30
Circle has
Center point
radius
//constructor
// code
//methods
public double getX(){return p.getX();}
public double getY(){return p.getY();}
public double getRadius(){return radius);}
}
Software engineering
31
Circle is
Center point
Circle has
radius
//constructor
// code
//methods
public double getRadius(){return radius);}
}
Software engineering
32
Exercises
Think about how you would represent a collection of
Software engineering
33
Instance Diagram
Shows examples (instances) of object and links
Also known as an Object diagram
Models static design/process view of system using
instances
Names are underscored
objectName: ClassName
Customer
accountNumber: int
creditLimit: int
withdrawCashATM()
checkBalanceATM()
A class
Software engineering
Helen:Customer
Assign values to
attributes
accountNumber = 3223589
creditLimit = 5000
An instance
Lecture Notes UML
34
Instance Diagram
Name of class is underlined and preceded by :
OOCorp:Company
Jerry: Employee
or, simplified
:Company
Software engineering
35
instances
An instance diagram is an example generated from a given
class diagram
Associations represent all possible links between two
classes
Links in instance diagrams do not have multiplicity (*)!
Employee *
class
diagram
worksFor
generates
Company
Mary: Employee
Jerry: Employee
Software engineering
OOCorp:Company
Instance diagram
36
Example
A Customer has at least 1 Account
Customer
has
1..*
Account
savingsAccount:Account
accountNumber= 3223589
creditLimit= 5000
accountType= Savings
monthlyFee= 5.00
Software engineering
37
Exercise
Generate an instance diagram for the CS230
Software engineering
38
Dynamic Behaviour
Document dynamic behaviour of software
system:
Visualise how system is run
Show communication between objects, i.e.
messages
Show the flow of events
Software engineering
39
Dynamic Behaviour
Represent using interaction diagrams
Sequence diagrams
can be
Collaboration diagrams
converted
Use instances of classes
Show the passing of parameters
Show method calls
Software engineering
40
object
Want to show sequence of calls, perhaps
arguments to calls, return values
ClassA
attributes
methods
Software engineering
ClassB
attributes
Return value D
methods
41
Sequence Diagrams
Shows sequence of messages exchanged by
Software engineering
42
Components specific to
sequence diagrams
Return value
Software engineering
Arguments
43
Example
Sequence of actions for withdrawing cash from an ATM
machine
:ATMMachine
:Customer
:Account
:Transaction
Self-call
getBalance( )
Lifeline
checkCRLimit( )
addTrans( )
Activation
Box
updateBalance( )
addTrans( )
dispenseCash( )
44
Example
Course registration
:CourseSection
Actor
requestToRegister
(aStudent)
:student
:Course
prereq:=
getPrerequisite
hasPrereq:=
hasPassedCourse(prereq)
[hasPrereq]
<<create>>
:Registration
addToSchedule
addToRegList
Software engineering
45
Collaboration Diagrams
Layout and components
Software engineering
46
Collaboration Diagrams
Self-call
:Class1
:Class3
4: func4()
Calling sequence #
3: func3()
2: func2(int,Class2) : boolean
1: func1(string)
:Class2
Called function name
Arguments
Software engineering
Return value
47
Collaboration Diagrams
ATM Withdraw cash collaboration diagram
6: dispenseCash( )
2: checkCRLimit( )
:ATMMachine
Withdraw
Cash
Software engineering
:Customer
4: updateBalance( )
5: addTrans( )
1: getBalance( )
3: addTrans( )
:Transaction
:Account
48
49
perform a transaction
:ATMMachine
Customer
:Card
insertCard()
requestPIN()
*[i=1:4]:
enterPINDigit()
Software engineering
Generic form
checkPIN()
[verified=true]
Proceed with
transaction
[verified=false]
Do something else
E.g. ATM eats the card
50
Example
Software engineering
51
Example
Software engineering
52
Exercise
Convert the course registration sequence
Software engineering
53
Detailed Descriptions
NOT sufficient to draw lots of diagrams.
Software engineering
54
Links
UML Resource Page
http://www.uml.org/
ArgoUML
http://argouml.tigris.org
Software engineering
55
What next??
Now have high-level specification for system data
& functions
Need more info in order to implement system:
software architecture to use
user interface vs. data management vs. processing
objects
data structures, data management
detailed OOD class/collaboration diagrams
detailed specifications of all design-level data/functions
Software engineering
56