ISYS2395 Session 10 SMD Exercise Sample Solution
ISYS2395 Session 10 SMD Exercise Sample Solution
Session 10
Alem Molla
Exercises
2
Exercise 1: Reflection
3
Exercise 2: States, Transitions,
Events
4
Exercise 2a Solution
States Events/Actions Transitions
Setup: Initial state Initialize account, Setup to active
when an account Change status
is created.
Active: most Dormant or Request Active to close;
account Close, Active to inactive
operations occur Deactivate
Inactive: Passage of time/User
temporarily request,
deactivated and Close account Inactive to close
can be
reactivated. Reactivate account Inactive to active
Closed : account No event (account End state
cannot be used cannot be transitioned
for transactions. out of this state)
5
Exercise 2a Solution
Setup Inactive
Reactivate
Active Closed
Close
6
Exercise 2b Solution
States Event /Action Transition
Idle: An initial state Card insertion Idle to active
of an ATM Action=reading card
Active: Ready to Incorrect PIN Active to idle
process inserted action = cancel
card
Active: Ready to Correct PIN Active to idle
process inserted action = transaction
card processed
Out of order: ATM Technical Idle to Out of order
not functioning failure/power failure
Fixed/power back
action= display
change
7
Exercise 2b: (High level)
state machine for ATM
Exercise 3: Uber SMD
9
Exercise 3 Solution for
Ride Object
States Event/Action Transition
Requesting: initial Notify drivers Searching
state when a user
requests a ride
Searching Driver accepts Driver assigned
User cancels ride Cancelled
Driver assigned Driver cancel ride Searching
Ride starting In progress
Cancelled None completed
In progress Trip Completed
Completed No event Final state
10
Exercise 3 Sample
Solution
Requesting Searching
Driver
cancels
User cancels Driver
found
Driver
Cancelled In progress Trip Completed
assigned Ride
start
11
Exercise 4: Project SMD
Create a simple
State Machine
Diagram(s)
12
Exercise 4 Solution
13
Exercise 5: Account SMD
For the user account to be created, it must meet some initial requirements. For
example, user id (used as a login name) must be unique, at least for the existing
accounts. After account was created, it might need to be verified. Verification
depends on the company and could include e-mail, phone, and/or address
verification. If account was not verified during some predefined period, that
account could be moved to the suspended accounts.
New, active, or suspended accounts could be cancelled at any time by client's
request. Note, the precondition for this usually includes payment of any
outstanding balances and might require some separate account state
or substate to handle this case.
User account might be suspended for security reasons, manually or
automatically. For example, website intrusion detection system locks user
account for predefined period, if there were several unsuccessful login attempts
using incorrect account password. After account lock times out, account is
activated back automatically.
Some user accounts could be inactive for a long period of time. Company policy
or business rules could require moving such dormant for a year or two accounts
to the suspended state.
14
Exercise 5 Solution
15
Exercise 6: Post-Class
Exercise Ticket Selling
16
Exercise 6: Sample
Solution Ticket Selling
System State Machine
18
References
19
Post Class Activities
20