Title: Object Oriented System Design COS 503
1Object Oriented System Design COS 50-3
- Marc Conrad
- D104 (Park Square Building)
- Marc.Conrad_at_luton.ac.uk
- Acknowledgement slides on this weeks lecture
mostly provided by Dayou Li.
2Sequence Diagram
- A sequence diagram shows how blocks (objects)
within a use case cooperate with each other. It
shows the occurrence of a sequence of events as
the responses to stimuli, which is called
stimuli-responses relationship or the internal
logic of a system. - A stimulus comes from a block and goes to another
block. It triggers a sequence of events in that
block. - The receiver may also send results (feedback)
back to the sender. - Events must be known before constructing a
sequence diagram.
3Sequence Diagram (Contd)
4Sequence Diagram
- Sequence diagram shows how blocks (objects)
within a used case cooperate with each other. It
shows the occurrence of a sequence of events as
the responses to stimuli, which is called
stimuli-responses relationship or the internal
logic of a system. - A stimulus comes from a block and goes to another
block. It triggers a sequence of events in that
block. - The receiver may also send results (feedback)
back to the sender. - Events must be known before constructing a
sequence diagram.
5Sequence Diagram (Contd)
Syntax and Semantics
signal (interprocess)
Blocks life line (showing life cycle)
message (intra-process)
Distinguishing a system and the outside
world (RationalRose Use Actors )
Events occurring within a block
feedback signal
6Sequence Diagram (Contd)
Pragmatics
- List all blocks right-hand side of the system
border, - Draw a life line for each block,
- List all events on the left-hand side of the
system border, - Draw vertical bars on the corresponding life
lines to represent the events. - Identify and draw signals,
- Identify and draw messages,
- Identify and draw feedback signals.
7Sequence Diagram (Contd)
Example (focusing on Returning item use case)
- Blocks
- -- Customer Panel,
- -- Deposit item receiver,
- -- Receipt basis,
- -- Deposit item,
- -- Receipt printer.
8Sequence Diagram (Contd)
- Events (when a customer insert an item)
If (customer is new) Create a new
account Do If (returned item is
acceptable true) Classify Increment
items Increment values else reject
9Sequence Diagram (Contd)
- Events (when the customer presses receipt
button) - Print Logo and date
- for (index 0 index lt 3 index )
-
- Find name and number for a type of item
- Find deposit value for a type of item
- Sum
- Print sum
-
- Ready for the next customer
10Sequence Diagram (Contd)
create
A new customer press start button
ready
new item
Do check classify Increment items, Increment
values, While (! receipt button pressed)
Item
items
inc item/value
11Sequence Diagram (Contd)
receipt
The customer presses the receipt button
printReceipt
print Logo, date
Print Logo and date, Find name and number for a
type of item, Find deposit value for a type of
item, Sum, Print sum
get value
value
get name
name
print
12Sequence Diagram (Contd)
receipt
The customer presses the receipt button
printReceipt
print Logo, date
Print Logo and date, Find name and number for a
type of item, Find deposit value for a type of
item, Sum, Print sum
get value
sum
value
get name
name
printSum
13Rational Rose Sequence Diagram
14Rational Rose Collaboration Diagram
15Case Study (Vehicle Hire Company)
EuroStar is a vehicle hire company. It provides a
variety of vehicles for its customers. Each
vehicle has a record in the companys database,
including Register Number, Maker, Model, Colour,
Engine Size, etc. The company has a manager and
a number of Register Staff. The register staff
takes a customers reservation and searches for a
vehicle that matches the order by sending a query
to the companys computerised database. When the
requested type of vehicle is available, the staff
confirms the reservation. If it is not available,
the staff gives suggestions of alternative
vehicle.
16Case Study (Vehicle Hire Company)
Customers are required to return vehicles to the
company before a Return Time. They are liable to
a fine if they return vehicles late. EuroStar
now wants to have a Web site in order that
customers can make their reservation through the
Internet. Suppose that you are working in a
software house and EuroStar is your client. You
are asked to develop such an on-line booking
system for the company.
17Requirement Model (use case)
-- customers
-- making a reservation
18Analysis Model (3-type objects)
19Design Model (sequence diagram)
- Events
- read customers request,
- form a query,
- search for a vehicle,
- find alternative if the request vehicle is
unavailable, - display alternative vehicle,
- set return time,
- display return time.
20Design Model (sequence diagram)
21COS50-3 OOSD
Object Oriented Design Model II (Week 5)
22Selection in SD
- If else
- Fork and condition repression.
- Branch of control in the receiving blocks
lifeline.
23Selection in SD (Contd)
A soda machine example Customers buy soda drinks
from a soda machine.
24Selection in SD (Contd)
When input (inserted coins ) price
25Selection in SD (Contd)
When input (inserted coins ) gt price
26Selection in SD (Contd)
- Selection requires a second life line. One
condition leads to the original life line and the
other condition leads to the second one.
Dispenser
Front
Register
27Control in SD
Synchronous and asynchronous
- A synchronous message/signal is a control which
has to wait for an answer before continuing.
Hence, the sender passes the control to the
receiver and cannot do anything until the
receiver sends the control back. - An asynchronous message is a control which does
not need to wait before continuing. Hence, the
sender actually does not pass the control to the
receiver. The sender and the receiver carry on
their work concurrently.
28Control in SD (Contd)
- Syntax
- Example the return item use case in the
recycling machine. - -- Concentrate on the rounded rectangle and
answer the question Should getName and getValue
be synchronous or asynchronous?
asynchronous
29Control in SD (Contd)
receipt
The customer presses the receipt button
printReceipt
print Logo, date
Print Logo and date, Find name and number for a
type of item, Find deposit value for a type of
item, Sum, Print sum
get value
value
get name
name
print
30Control in SD (Contd)
On one hand, getValue signal and getName signal
can be asynchronous as the system does not need
to wait for values before requesting name. On
the other hand, print message could be sent out
to the printer if getValue and getName were
asynchronous. For this reason, getValue signal
and getName signal must be synchronous.
31Control in SD (Contd)
receipt
The customer presses the receipt button
printReceipt
print Logo, date
Print Logo and date, Find name and number for a
type of item, Find deposit value for a type of
item, Sum, Print sum
get value
value
get name
name
print
32Control in SD (Contd)
- Concentrate on other signals and messages.
- -- receipt signal it does not even need a
feedback. Therefore, it can asynchronous. - -- printReceipt signal it can be asynchronous,
too. - -- printLogo, date message it can also be
asynchronous, as no feedback is required.
33Control in SD (Contd)
receipt
The customer presses the receipt button
printReceipt
print Logo, date
Print Logo and date, Find name and number for a
type of item, Find deposit value for a type of
item, Sum, Print sum
get value
value
get name
name
print
34Recursion in SD
- Recursion or self-call -- an object/block may
have an operation that invokes itself. - Example (personal loan)
Year(0) loan(0) Year(1) loan(1) loan(0) ? (1
interestRate) Year(2) loan(2) loan(1) ? (1
interestRate) loan(0) ? (1
interestRate) ? (1 interestRate) Year(3)
loan(3) loan(2) ? (1 interestRate)
loan(1) ? (1 interestRate) ? (1
interestRate) loan(0) ? (1
interestRate) ? (1 interestRate)
? (1 interestRate)
35Recursion in SD
36Structure of SD
- Centralised structure -- Fork Everything is
handled and controlled by the left-most block.
37Structure of SD (Contd)
- Decentralised structure -- Stair There is no
central control block.