Se201 Lecture 9
Se201 Lecture 9
Se201 Lecture 9
EXAMPLE
Draw a UML Class Diagram representing the following elements from the problem domain for a hockey
league.
Draw a class diagram for this information, and be sure to label all associations with appropriate
multiplicities.
SOLUTION
A hockey league is made up of at least four
hockey teams.
Each hockey team is composed of six to twelve
players, and one player captains the team.
A team has a name and a record.
Players have a number and a position.
Hockey teams play games against each other.
Each game has a score and a location.
Teams are sometimes lead by a coach.
A coach has a level of accreditation and a
number of years of experience, and can coach
multiple teams.
Coaches and players are people, and people
have names and addresses.
SEQUENCE DİAGRAM
From the flow of events in the use case or scenario proceed to the sequence
diagram
A sequence diagram is a graphical description of the objects participating in
a use case using a DAG (directed acyclic graph) notation
Relation to object identification:
Objects/classes have already been identified during object modeling
Objects are identified as a result of dynamic modeling
Heuristic for finding participating objects:
A event always has a sender and a receiver
The representation of the event is sometimes called a message
Find them for each event => These are the objects participating in the use case.
LİFELİNES
Object1
Underline on name
indicates object (vs class)
Represents time during
which the object exists.
Return
The reply to a synchronous
message Often not shown
Flat
Don’t know or don’t care
SYNCHRONOUS MESSAGES
Used when we don’t want to specify whether or not sender waits for a reponse.
Haven’t decided yet.
Isn’t important
Specifically want to leave as an implementation decision.
MESSAGES
Messages are identified by a name, with the optional specification of parameters and a
return value.
The parameters are separated by commas and are enclosed within parentheses.
The return value can optionally be assigned to a variable as well.
Thus, a message can be labeled with var=m1:value, whereby var is the variable to
which the return value is to be assigned, m1 specifies the name of the message, and
value represents the actual return value.
SEQUENCE DİAGRAM
SEQUENCE DİAGRAM
Time Increasing -->
Lower = Later!
COMPONENTS
Generic
Generic (unnamed)
(unnamed)
Specific
Instance of an objects ofobjects
class type Seminar
Object and Course
COMPONENTS
execution
lifeline
COMPONENTS
Method call
Return value
A SİMPLER EXAMPLE - SENDİNG AN EMAİL
WORKİNG FROM A SCENARİO
Sending an email
If this is an interactive scenario, we always have an actor driving it, so we put one on
the sequence diagram
: user
ADD OBJECTS
The first interaction is with the icon bar, which we can treat as an object
: icon bar
: user
ADD MESSAGE
: icon bar
: user
LABEL THE COMMUNİCATİON
: icon bar
: user
click send mail
Remember that actors can only communicate with interface objects such as screens,
menus and icon bars.
THE İCON BAR HAS SOME WORK TO DO.
It creates an email page.
: user
click send mail create
Now the user can see the email page and use it.
The next three steps are filling in the details on the email page
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
THE USER THEN CLİCKS SEND
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
NOW CONSİDER HOW TO DO THE SENDİNG
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
submit email
And if we think carefully, the email page always closes after the send.
: user
click send mail create
fill in to box
fill in subject box
fill in contents box
send
look up email address
submit email
close
Now we go through and change the messages to operations on the
object
: user
send mail( ) create
fill in to box
fill in subject box
fill in contents box
send
look up email address
submit email
close
And so on, all the way through
: icon bar : email page : address book : email server : icon bar : email page : address book : email server
: user : user
click send mail create send mail( ) create( )
send send( )
look up email address getEmailAddress( )
close close( )
USİNG SCENARİOS
Payday
Interactions between actors: This is a form of instance diagram: it just shows one example of
what could occur
Sequence diagram
use-case check in jo : Person chris: Receptionist rms: Room Manager System
Person arrives at desk, arrive
gives name.
get room map
R gets map of available choose room
Rooms, chooses one.
get details
R enters Person’s details person details
time
on Room Management
system against chosen confirm room assignment
room.
R gives key to Person. key
•Librarian
•Online Library Management system
•User credentials database
•Email system
EXAMPLE
Every time a member enters the club, an attendant takes his or her card and
scans it to make sure that the person is an active member. If the member is
not active, the system presents the amount of money it costs to renew the
membership. The customer is given the chance to pay the fee and use the
club, and the system makes note of the reactivation of the account so that
special attention can be given to this customer when the next round of
renewal notices is dispensed.
EXAMPLE
EXAMPLE (CONT.)
EXAMPLE
REFERENCES