Lecture 7
UML Worked Example
SpecificationThe city of Coruscant has an underground shuttle system that runs between the Spaceport, the Jedi Council Room, the Senate Chamber and the Restaurant complex. Citizens may summon the shuttle at any of the stations by pressing a button. Travellers on the shuttle can press a button to indicate their required destination station. The shuttle only stops at stations to which it has been directed. When there are no travellers it remains at the last station it arrived at, unless there are no passengers for over 2 minutes, in which case it returns to the Spaceport.
Use Case Diagram
Call shuttle
Choose destination
Citizen
Traveller
Use Case Diagram – more?
Call shuttle
Choose destination
Citizen
Traveller
ShuttleMove to station
extends
extends
Finding classes – step 1The city of Coruscant has an underground shuttle system that runs between the Spaceport, the Jedi Council Room, the Senate Chamber and the Restaurant complex. Citizens may summon the shuttle at any of the stations by pressing a button. Travellers on the shuttle can press a button to indicate their required destination station. The shuttle only stops at stations to which it has been directed. When there are no travellers it remains at the last station it arrived at, unless there are no passengers for over 2 minutes, in which case it returns to the Spaceport.
city of Coruscant underground shuttle system Spaceport Jedi Council Room, Senate Chamber Restaurant complex. Citizens shuttle stations button. Travellers shuttle button destination station. shuttle stations travellers station passengers minutes, Spaceport.
Finding classes – step 2Group together related or associated nounsDecide if they make
one class, an attribute of another class
Candidate classesTraveller
But this is an actor – outside the systemStation
Does this do anything?Shuttle
Main problem!Button
Only form of interface?
Class diagram
ShuttleCurrent posDestinationMinutes
Stop()Move()
ButtonPressed
Press()
station
Write Use Case examplesJabba the Hutt, at the Restaurant Complex calls the shuttleLuke, who is on the shuttle, wants to go to the Senate Chamber
Sequence diagram (1) <<Jabba>>
:passenger
:Button :Shuttle :Controllersummon shuttle
stationstation
Destination addedCall acceptedCall accepted
Move to destination
Arrived at destinationArrive
dShuttle arrives
Sequence diagram (2):Button :Shuttle :Controller
Choose destinationstation
station
Destination addedCall acceptedCall accepted
<<Luke>>:passenger
Move to destination
Arrived at destinationArrive
dShuttle arrives
From the sequence diagramUpdate your class diagram
Button looks like it might be more than just a buttonShuttle needs to have some sort of data controller to store destinations
From each sequenceFor each relevant class• Produce a State transition diagram
Shuttle STD – from seq.diag 1
At stationCreating
new destination
Moving to destination
Receive station/destination
Destination confirmedArrive at
destination
Shuttle STD – from seq.diag 1
At stationCreating
new destination
Moving to destination
Receive station/destination
Destination confirmedArrive at
destination
Design and CodingButton
May be more complex than just a buttonProgrammer needs to develop usable interface• Information user wants• Constraints of the language/hardware
Design & codingShuttle
Needs a data storage to hold the destination(s)Has other functionality• E.g. Returns to base after 2 mins
– Requires a timer
• May need to “optimise” movement– Work out which is the next destination