CS计算机代考程序代写 database chain Java case study 300144

300144
Object Oriented Analysis
Dr Mahsa Razavi
Object Oriented Analysis – 300144 1

Lecture 7
Sequence, Interaction Overview & State Machine Diagrams
References
Textbook Chapter 7, 10, 12
Bhuvan’s book Chapter 7
Booch’s book Chapter 5.8, 5.9, 5.11, 9
Object Oriented Analysis – 300144 2

Things in Last Lecture
• Revisiting Class and Object
• Class documentation and UML Class Notation
• Major Ingredients of Class Diagram
• Relationships in Class Diagram: – Inheritance, Association & Aggregation
• Multiplicities in Class Diagram
Object Oriented Analysis – 300144
3

“Patient Details” Class Diagram
Person
-FirstName -LastName -DateOfBirth
Address
Medicine
-MedStaff -MedDivisions
+bookAppointment() +getTreatment()
PrivatePatient
-InsuranceCompany -DateStarted -DateOfExpiry -LevelOfCover
+submitInsuranceClaim ()
+createPerson() +changePeson () +calculateAge() +getPerson ()
+getPatientDetails ()
PublicPatient
1..*
-StrNo -StrName -City -PostCode -Country
Patient
+createAddress () +maintainPhone() +getPhone ()
-PatientID -MedicareCard -EmergancyContact
1
1..*
Phone
0..*
-STDCode -PhoneNumber -PhoneType
+createPhone () +maintainPhone() +getPhone ()
Public Patients have medicare card details
+submitMedicareClaim () 4

Main Topics of Lecture
• Major Ingredients of Sequence Diagram
• ImportanceandRelevanceofSequenceDiagram
in Analysis
• Interaction Overview Diagrams
• State Machine Diagrams in Dynamic Modelling
Object Oriented Analysis – 300144 5

Sequence Diagram
Object Oriented Analysis – 300144 6

Major Ingredients of a Sequence Diagram
The Actor
1: enquiresAvailability
Message
Self Message
: Patient
aPatient :Patient
Object
Time Line
Focus of Control
Patient Checks Availability of Doctor
Steps in the Sequence
Notes
Object Oriented Analysis – 300144
7

Sequence Diagram
• Represent a scenario in the system
• Dynamicinteractionsbetweencollaborating
objects in the system
– Show a set of collaborating objects, messages passing between them, and timing
– ideal in showing “what happens” in the system – a good “whiteboard” technique to capture the
examples of requirements described by users
Object Oriented Analysis – 300144 8


• •
How to Build a Sequence Diagram
Identify Objects that participate in an interaction
– Objects are then arranged from left to right on the diagram
A timeline drops downwards from each of the objects
Horizontal arrows are drawn corresponding to each message
– Message can be related to a step in a use case documentation or to an activity on the activity diagram
– Message should have corresponding operations in the class
Object Oriented Analysis – 300144 9

A Basic Sequence Diagram
Object
System
: ActorPatient
checkAvailability()
showAvailabilityToPatient
: ActorPatient
checkAvailability( )
return message
Sequence Diagrams show the instance level Sequence of Interactions between Objects, System and, occasionally, Actors
Object Oriented Analysis – 300144 10
aDoctor :
Doctor

A Basic Sequence Diagram
Object
aDoctor :
Doctor
: ActorPatient
checkAvailability()
showAvailabilityToPatient
: ActorPatient
checkAvailability( )
return message
System
• A return message is shown by a broken-line arrow.
• However, to improve the simplicity and visual clarity, return messages
are not normally shown on the diagram. We assume that there is always
Sequence Diagrams show the instance level
a return message for each interaction.
Sequence of Interactions between Objects, System and, occasionally, Actors
Object Oriented Analysis – 300144 11

“Registering a Patient “ Sequence Diagram
: ActorPatient : Administrator AnnounceArrival()
EnterDetails()
GHRS
CreatePatientRecord()
CreatePatientRecordID()
System
ProvideDetails()
VerifyDetails()
This is a hypothetical object meant to represent actor system interaction. Real objects will replace the system object shown here in detailed diagrams
Separate Sequence Diagrams will apply if Insufficient Details are provided by Patients
VerifyMedicalInsuranceDetails()
Object Oriented Analysis – 300144 12

“Updating a Calendar“ Sequence Diagram
: Staff
ShowCalendar()
GetCalendar()
aInterface
aCalendar :
Calendar
EnterRosterDetails()
VerifyCalendar()
AcceptedRosterDetails()
ValidateRosterDetails()
Separate Sequence diagrams need to be created if there are conflicting Rosters
UpdateCalendar()
Object Oriented Analysis – 300144 13

“Booking a Consultation “ Sequence Diagram
: ActorPatient
aInterface :Physician
: Calendar
SpecifyInitialConsultationDetails()
ProvidePhysicianList()
GetAvailableDate&Time()
SelectPhysician()
Calendar is separately updated by Doctor (Staff) in terms of their availability
SelectDate&Time()
UpdateCalendar()
ConfirmDate&Time()
Object Oriented Analysis – 300144 14

“Booking a Consultation “ Sequence Diagram
: ActorPatient
aInterface :Physician
: Calendar
SpecifyInitialConsultationDetails()
ProvidePhysicianList()
What are
SelectPhysician()
missing on the
GetAvailableDate&Time()
SelectDate&Time()
diagram?
UpdateCalendar()
Calendar is separately updated by Doctor (Staff) in terms of their availability
ConfirmDate&Time()
Object Oriented Analysis – 300144 15

“Paying a Bill “ Sequence Diagram
: ActorPatient
displayPayment( )
: BPay
: Bill
VeirfyBpayStatement()
acceptPayment( )
ConfirmReceipt()
GenerateReceipt()
UpdateBill( )
Object Oriented Analysis – 300144 16

Objects on Sequence Diagrams belong to Classes in Class Diagram
Relating Sequence Diagrams to Class Diagrams
aPatient:Patient
1: checkPatientDetails( )
Patient
checkPatientDetails( )
Messages on Sequence Diagrams come from Methods available to the Class on Class Diagrams
Object Oriented Analysis – 300144 17

id: String,
1.2:sedId(id:String=id):void
https://www.visual-
paradigm.com/tutorials/seqrev.jsp
Object Oriented Analysis – 300144 18
An Java Program’s Sequence

An Java Program’s Sequence (Cont.)
import java.util.*;
import java.io.* ;
public class AccountRegistration {
public static void main( String args[] ) throws IOException { ……
RegisterController aRegisterController = new RegisterController(); do {
System.out.print( “\nEnter ID (4 digits), name and age for registration.\n” +”Input an ID with FOUR ZEROS to end the program.\n” );
……
aRegisterController.register(id, name, age) ; //1: register
}while (!(id.equals(“0000”))); ……
List accountArray=aRegisterController.getAccounts();//1.6
……
Object Oriented Analysis – 300144 19

public class Account { private String _id;
private String _name; private int _age;
public void setId(String id){
_id = id; }
public String getId(){
return _id; }
public void setName(String name){
_name = name; }
public String getName(){
return _name; }
public void setAge(int age){
_age = age; } public int getAge(){
return _age; } ……
}
300144 20
import java.util.*;
public class RegisterController {
private List _accounts = new ArrayList(); //* public void register(String id, String name, int age) {
Account account = new Account();//1.1 account.setId(id); //1.2 account.setName(name); //1.3 account.setAge(age); /1.4 _accounts.add(account); //1.5 *
}
public List getAccounts(){
return _accounts; }
}
An Java Program’s Sequence (Cont.)
Object Oriented Analysis –

SWOT of a Sequence Diagram
STRENGTHS:
Show the dynamic behavior
of the system
Show a set of collaborating objects, messages passing between them, and timing
Ideal “snap shot” representation of ‘what happens’
WEAKNESSES:
Snapshots, hence incomplete Presents behavior, but still not considered truly Dynamic by many
OBJECTIVES:
Show the interaction between Actor and system typically as an ‘example’ within a use case
Show the message passing between collaborating objects or system and actor Messages with their signatures provide direct information to programmers
Mechanism to help users build storyboards Mechanism to discover Classes and Methods
TRAPS:
Attempting to show a ‘complete’ sequence is a major trap – do not try to complete everything in a sequence diagram Inappropriate level of usage (BA trying technical, and vice versa)
Object Oriented Analysis – 300144 21

Interaction Overview diagrams
Object Oriented Analysis – 300144 22

Interaction Overview Diagram
• Provides a high-level overview of the interactions happening within the system
– show dependencies and flows between use cases – might contain reference sequence diagrams
• Has all the ingredients of Activity Diagram
• Question: what is the difference between an interaction overview diagram and an activity diagram?
Object Oriented Analysis – 300144 23

Ingredients of an Interaction Overview Diagram
Start Stop
Reference
(to a Use Case or a Sequence Diagram )
Decision
Flow
Fork / Join
Note
ref
EnquirySequence
Object Oriented Analysis – 300144
24

“Consultation Details “ Interaction Overview Diagram
ref ChecksCalendar
NO
Check the Calendar
again for Alternatives.
If no bookings available,
no consultation takes place
“BookingAvailable?”
YES
ref BooksConsultation
ref ExaminesPatient
Interaction Overview Diagrams reference Sequence diagrams or Use cases, providing an overview of flow between them.
ref OrdersTests
ref
W ritesPrescriptions
Object Oriented Analysis – 300144 25

“ Accounting“ Interaction Overview Diagram
ref PaysBill
Method
CashCheque
BPAY
CARD
ref PaysBillByCard
ref PaysBillOnInternetBPAY
ref CashChequePayment
Private?
YES NO
ref PlacesInsuranceClaim
Object Oriented Analysis – 300144 26

Strengths and Weaknesses of Interaction Overview Diagram
• Strengths:
– Showthedependenciesbetweenvarioussequenceswithinthesystem
– Displayofconditionsandmultiplethreadsonthediagram
– Showthenormalandalternativeflowsofsequenceswithinthe system through a combination of flowchart and references
• Weaknesses:
– Notabletoshowthe“instance”levelmodelling
– Excessive modelling with interaction overview diagrams may lead to confusion with the activity diagram
– Possible confusion to what is being referenced (sequence diagram, communication diagram or a user case?) within the interaction overview diagram.
Object Oriented Analysis – 300144 27

State Machine Diagrams Part of Dynamic Modeling
Object Oriented Analysis – 300144 28

Ingredients of a State Machine Diagram
Start State
Stop State
Transition
& Self-Transition
State
Nesting
Decision Point
Notes
[ CorrectDetails ] / acceptPolicy
Guard Condition/ Action
Object Oriented Analysis – 300144
29

States, Transitions
• States Describe the Values of Attributes of an Object
• An object in a State: – Performs some action. – Waits for an event.
• Transition makes an object change its State
Object Oriented Analysis – 300144 30

Initial and Final States
• StartState
– The state of the object at the start of its lifetime. – A statechart must have exactly one start state.
• StopState
– The state of the object at the end of its lifetime.
– Optional – a statechart will not have a stop state if the object is never destroyed.
– A statechart can have many stop states.
Object Oriented Analysis – 300144 31

How to Build a State Chart?
• DeterminetheSequencesandEventsthatinvolve this Object
• For each event, determine the effect it has on the state of the object.
• Apply transitions to the states of an Object
• Add guard conditions associated with the event.
• Determine Nested and Historical States
• Only for Complex, Dynamic and/or Important Objects
Object Oriented Analysis – 300144 32

“Patient “ State Machine Diagram
Registered
For OutPatient, follow Consulation StateChart
Admitted
Operated
Recovered
Released
Surgical
Yes No Consulting
Object Oriented Analysis – 300144 33

“Consultation“ State Machine Diagram
Open
Available
Booked
[ Cancelled ]
SuperStates for Consultation Objects
Closed
Provided
Billed
Object Oriented Analysis – 300144 34

“Bill Payment“ State Machine Diagram
Generated
Issued
[ PastDueDate ]
Yes
PartPaid
Overdue
Paid?
No Defaulted
Paid
Object Oriented Analysis – 300144 35

Object’s State in Java Program
https://sourcemaking.com/design_patterns/state/java/2
Turning Off
High Speed
[Press Enter]
Low Speed
Medium Speed
Fan Speed State Machine Diagram
Object Oriented Analysis – 300144
36

Object’s State in Java Program (Cont.)
class CeilingFanPullChain {
private int m_current_state;
public CeilingFanPullChain()
{ m_current_state = 0; } //Initial state “turning off”, may set a random state public void pull() //change states of fan
{ if (m_current_state == 0) { //after Press Enter m_current_state = 1; System.out.println(” low speed “);
}
}
} }
else if (m_current_state == 1) { //after Press Enter m_current_state = 2; System.out.println(” medium speed”);
else if (m_current_state == 2) { //after Press Enter
m_current_state = 3; else {
m_current_state = 0;
System.out.println(” high speed”); //after Press Enter
} }
System.out.println(” turning off”); Object Oriented Analysis – 300144
37

Object’s State in Java Program (Cont.)
import java.io.*;
public class StateDemo {
public static void main(String[] args) { CeilingFanPullChain chain = new CeilingFanPullChain(); while (true) {
System.out.print(“Press Enter”); get_line(); //Press Button chain.pull(); //Change fan state }
}}
public static String get_line() {
BufferedReader in = new BufferedReader(new InputStreamReader (System.in)); String line = null;
try {
line = in.readLine(); return line;
} }
} //……
Object Oriented Analysis – 300144 38

SWOT of a State machine Diagram
STRENGTHS:
Represents the ‘lifecycle’ of an object or a business entity Demonstrates the dynamic aspect of the system
WEAKNESSES:
Deals with only one
object’s lifecycle
Remains Incomplete as does not show all objects and all states and transitions in one diagram
OBJECTIVES:
Display the changes to the state of an object, and events that create those changes Extensively used in Modeling of real-time system
TRAPS:
Confusing with Activity diagrams Too many technical details in business-level diagrams
Object Oriented Analysis – 300144 39

Workbook
Exercises
For The Class Room!!
Object Oriented Analysis – 300144 40

A Sample of “Making A New Booking” Sequence Diagram
• The Sequence diagram is shown during the lecture.
• This Sequence diagram is created based on Use Case “NewBooking” of Lecture 4.
Object Oriented Analysis – 300144 41

Use Case – NewBooking
Use Case Thumbnail: UC10-NewBooking
Actors: A20-OnlineCustomer, A130-OnlineCustOperator, A00-
Printer
Use Case Description: this use case deals with booking a new travel online. A20-OnlineCustomer selects destinations, date and time and any associated activities, such as car rental, hotel, etc. A20-OnlineCustomer also need to log onto the system in order to confirm the booking and pay the fee. The customer operator must double check the booking and contacting the customer if required. A receipt will be given to the customer.
Pre-Conditions: N/A.
Post-Conditions: Booking is issued with the receipt.
Object Oriented Analysis – 300144 42

Use Case for NewBooking (Cont.)
Basic Flow:
1. A20-OnlineCustomer requests a travel booking with the system.
2. The system provides the travel booking page with destinations, date/time and preferable carrier(s).
3. The customer selects the destinations, date/time, and carrier preference.
4. The system displays the matching information (A1).
5. The customer selects a trip (A2).
6. The system confirms the travel detail and offer suggestion for associated activities including car rental, hotel and tour.
7. The customer selects an associated activities (A3).
1. Book a car/hotel/tour use case
8. The system updates the booking record
9. The customer logs onto the system to confirm the booking and pay the fee (A4)
10.The system acknowledges the booking with a receipt to the customer.
11.A130-OnlineCustOperator checks the booking onsite (A5) 1. Operator checking use case
Object Oriented Analysis – 300144 43

Use Case for NewBooking (Cont.)
Alternative Flow:
A1 – There is no matching travel. The customer is asked to change the information, such as date/time and preferable carriers
A2 – The customer does not like the recommendation. The system provides new travel information according to the new preference.
A3 – No other activity is selected. The system moves to the next step.
A4 – Invalid login detail. The system asks the customer to enter the login information again or register detail if he/she is a new customer.
A5 – If further information is required from the booking, the OnlineCustOperator contacts the customer directly.
Object Oriented Analysis – 300144 44

Object Oriented Analysis – 300144 45
A Sample Activity Diagram

A Sample of “Making A New Booking” Sequence Diagram
Object Oriented Analysis – 300144 46

An Example State Machine Diagram of Applied Project
“Property
For Sale” State Machine Diagram
Open
For Sale
[Cancelled]
Under Contract
Sold
Exchange Contract
Settled
0.25% paid
10% paid
Pay the ballance
Object Oriented Analysis – 300144
47

Conclusions
• Sequencediagramsin
✓Interaction between Collaborating Objects ✓Interaction between Actors and System.
• Interaction overview diagram provides a high- level overview of the interactions happening within the system
• State machine diagrams show various states of the object during its lifecycle.
Object Oriented Analysis – 300144 48

Project Work :
(During Tutorials in the Lab);
Follow the Project Work Requirements given at the End of the Chapter;
Discuss Project Work with Team Members and Tutor;
Carry Out the Project Work
Object Oriented Analysis – 300144 49

RUP Case Study – Train Traffic Management System (TTMS)
Elaboration-2
Object Oriented Analysis – 300144 50

Defining the TTMS Architecture
• A much more thorough analysis of the functionality required by all the use case scenarios, including the impact of the non- functional requirements and constraints, leads us to a block diagram for the Train Traffic Management System’s major elements.
Object Oriented Analysis – 300144 51

Defining the TTMS Architecture (Cont.)
Object Oriented Analysis – 300144 52

Defining the TTMS Architecture (Cont.)
• The following diagram illustrates the target deployment hardware for the Train Traffic Management System, using the notation for deployment diagrams.
• The hardware architecture parallels the block diagram of the system shown in the preceding slide
Object Oriented Analysis – 300144 53

Defining the TTMS Architecture (Cont.)
Object Oriented Analysis – 300144 54

From Systems- to Hardware/ Software- Engineering
• Further analyses the system’s functionality with more activity diagrams to provide a clear perspective of the work including each of system element and their collaboration in different scenarios.
• Use sequence diagrams, class diagrams, and Prototypes for more specific detail of the interactions at lower levels of the architectural hierarchy
Object Oriented Analysis – 300144 55

From Systems- to Hardware/ Software- Engineering
• The following sequence diagram captures one simple scenario for the automated processing of a daily train order and provides more detail into the inner workings of the Train Traffic Management System than does the activity diagram presented earlier
Object Oriented Analysis – 300144 56

A Scenario for Processing Daily Train Orders
Object Oriented Analysis – 300144 57

Key Abstractions and Mechanisms
• A study of the requirements for the Train Traffic Management System suggests that four different sub-problems to be solved (as given earlier in the Package Diagram):
1. Networking 2. Database
3. Human/machine interface
4. Real-time analogue and digital device control
Object Oriented Analysis – 300144 58

Key Abstractions and Mechanisms (Cont.)
• A brief domain analysis across these four sub- problem areas, we find that there are three common high-level key abstractions:
1. Trains: including locomotives and cars
2. Tracks: encompassing profile, grade, and wayside devices
3. Plans: including schedules, orders, clearances, authority, and crew
Object Oriented Analysis – 300144 59

Key Abstractions and Mechanisms (Cont.)
• A key mechanism for each of the four sub- problems includes:
1. Message passing
2. Train schedule planning
3. Displaying information
4. Sensor data acquisition
Object Oriented Analysis – 300144 60