Download presentation
Presentation is loading. Please wait.
1
Object Oriented System Design COS 50-3
Marc Conrad D104 (Park Square Building) Acknowledgement: slides on this week’s lecture mostly provided by Dayou Li. 07/11/ :01:08 Marc Conrad - University of Luton
2
Marc Conrad - University of Luton
Sequence 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. 07/11/ :01:08 Marc Conrad - University of Luton
3
Sequence Diagram (Cont’d)
Events 07/11/ :01:08 Marc Conrad - University of Luton
4
Marc Conrad - University of Luton
Sequence 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. 07/11/ :01:08 Marc Conrad - University of Luton
5
Sequence Diagram (Cont’d)
Syntax and Semantics signal (interprocess) Block’s 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 07/11/ :01:08 Marc Conrad - University of Luton
6
Sequence Diagram (Cont’d)
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. 07/11/ :01:08 Marc Conrad - University of Luton
7
Sequence Diagram (Cont’d)
Example: (focusing on Returning item use case) Blocks: -- Customer Panel, -- Deposit item receiver, -- Receipt basis, -- Deposit item, -- Receipt printer. 07/11/ :01:08 Marc Conrad - University of Luton
8
Sequence Diagram (Cont’d)
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; 07/11/ :01:08 Marc Conrad - University of Luton
9
Sequence Diagram (Cont’d)
Events (when the customer presses receipt button): Print Logo and date; for (index = 0; index < 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; 07/11/ :01:08 Marc Conrad - University of Luton
10
Sequence Diagram (Cont’d)
System border Customer panel Dep item receiver Receipt basis Dep item Rec. printer start 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 07/11/ :01:08 Marc Conrad - University of Luton
11
Sequence Diagram (Cont’d)
System border Customer panel Dep item receiver Receipt basis Dep item Rec.t printer 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 07/11/ :01:08 Marc Conrad - University of Luton
12
Sequence Diagram (Cont’d)
System border Customer panel Dep item receiver Receipt basis Dep item Rec. printer 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 sum get value value get name name printSum 07/11/ :01:08 Marc Conrad - University of Luton
13
Rational Rose – Sequence Diagram
07/11/ :01:08 Marc Conrad - University of Luton
14
Rational Rose – Collaboration Diagram
07/11/ :01:08 Marc Conrad - University of Luton
15
(Vehicle Hire Company)
Case 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 company’s 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 customer’s reservation and searches for a vehicle that matches the order by sending a query to the company’s 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. 07/11/ :01:08 Marc Conrad - University of Luton
16
(Vehicle Hire Company)
Case 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. 07/11/ :01:08 Marc Conrad - University of Luton
17
Requirement Model (use case)
-- customers -- making a reservation 07/11/ :01:08 Marc Conrad - University of Luton
18
Analysis Model (3-type objects)
Console -- interface between the system and the user, an interface object. Database -- vehicle records and availability, an entity object. Register -- Control of data flow, a control object. 07/11/ :01:08 Marc Conrad - University of Luton
19
Design Model (sequence diagram)
Console Register Database Events: read customer’s 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. 07/11/ :01:08 Marc Conrad - University of Luton
20
Design Model (sequence diagram)
Console Register Database Do read customer’s request, form a query, search for a vehicle, if unavailable find alternative display alternative, else set return time, display return time; While submit a request 07/11/ :01:08 Marc Conrad - University of Luton
21
Object Oriented Design Model II (Week 5)
COS50-3 OOSD Object Oriented Design Model II (Week 5) 07/11/ :01:08 Marc Conrad - University of Luton
22
Marc Conrad - University of Luton
Selection in SD If… else… Fork and condition repression. Branch of control in the receiving block’s lifeline. 07/11/ :01:08 Marc Conrad - University of Luton
23
Selection in SD (Cont’d)
A soda machine example: Customers buy soda drinks from a soda machine. Register Front Dispenser 07/11/ :01:08 Marc Conrad - University of Luton
24
Selection in SD (Cont’d)
When input (inserted coins ) = price System border Front Register Dispenser Insert Select Send Send Delivery 07/11/ :01:08 Marc Conrad - University of Luton
25
Selection in SD (Cont’d)
When input (inserted coins ) > price System border Front Register Dispenser Insert Select Send Delivery Send (input = price) Check for change (input > price) Return change Send (input > price) Delivery 07/11/ :01:08 Marc Conrad - University of Luton
26
Selection in SD (Cont’d)
Selection requires a second life line. One condition leads to the original life line and the other condition leads to the second one. Front Register Dispenser Original life line Second life line Delivery Send (input = price) Check for change (input > price) Return change Send (input > price) 07/11/ :01:08 Marc Conrad - University of Luton
27
Marc Conrad - University of Luton
Control 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. 07/11/ :01:08 Marc Conrad - University of Luton
28
Marc Conrad - University of Luton
Control in SD (Cont’d) 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? synchronous asynchronous 07/11/ :01:08 Marc Conrad - University of Luton
29
Marc Conrad - University of Luton
Control in SD (Cont’d) System border Customer panel Dep item receiver Receipt basis Dep item Receipt printer 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 07/11/ :01:08 Marc Conrad - University of Luton
30
Marc Conrad - University of Luton
Control in SD (Cont’d) 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. 07/11/ :01:08 Marc Conrad - University of Luton
31
Marc Conrad - University of Luton
Control in SD (Cont’d) System border Customer panel Dep item receiver Receipt basis Dep item Receipt printer 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 07/11/ :01:08 Marc Conrad - University of Luton
32
Marc Conrad - University of Luton
Control in SD (Cont’d) 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. 07/11/ :01:08 Marc Conrad - University of Luton
33
Marc Conrad - University of Luton
Control in SD (Cont’d) System border Customer panel Dep item receiver Receipt basis Dep item Receipt printer 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 07/11/ :01:08 Marc Conrad - University of Luton
34
Marc Conrad - University of Luton
Recursion in SD Recursion or self-call -- an object/block may have an operation that invokes itself. Example (personal loan): Operation that invokes itself 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); First called for lump sum Second called for new capital 07/11/ :01:08 Marc Conrad - University of Luton
35
Marc Conrad - University of Luton
Recursion in SD Syntax: 07/11/ :01:08 Marc Conrad - University of Luton
36
Marc Conrad - University of Luton
Structure of SD Centralised structure -- Fork: Everything is handled and controlled by the left-most block. 07/11/ :01:08 Marc Conrad - University of Luton
37
Structure of SD (Cont’d)
Decentralised structure -- Stair: There is no central control block. 07/11/ :01:08 Marc Conrad - University of Luton
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.