© 2008 prentice hall, ovidiu noran lecture 7b 1 modelling oo logic requirements: sequence diagrams...
TRANSCRIPT
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 1
Lecture 7b
Modelling OO Logic Requirements: Sequence Diagrams and Activity
Diagrams
(Textbook Chapter 8, Appendix)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 2
Learning Objectives
Understand how to detail use cases and represent some system logic with sequence diagrams.
Understand how to represent processes and system logic with activity diagrams.
Understand the relationship between different types of diagrams
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 3
Interaction and Activity Diagrams
Use Case diagrams are too simple to show details of the interactions among objects within a use case.
In addition to written use cases, Interaction Diagrams (Sequence and Collaboration) are used to detail the interactions taking place in a use case
Activity Diagrams are used to show the conditional logic for the sequence of system activities needed to accomplish a business process.
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 4
Dynamic Modelling: Sequence Diagrams
Sequence diagram: depicts the interactions among objects during a certain period of time.
May be presented either in a generic form or in an instance form.
Generic form shows all possible sequences of interactions, corresponding to all the scenarios of a use case.
Instance form shows the sequence for only one scenario (a specific combination of conditions within a use case (Fowler, 2000))
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 5
Elements of a sequence diagram Objects: represented by boxes at top of
diagram. Lifeline: the time during which an object
exists. Messages: means by which objects
communicate with each other. Objects (derived out of classes) and
messages are essential elements of the OO approach. More in future lectures…
Sequence Diagrams (Cont.)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 6
Activation: the time period during which an object performs an operation.
Synchronous message: a type of message in which the caller has to wait for the receiving object to finish executing the called operation before it can resume execution itself.
Sequence Diagrams (Cont.)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 7
Simple message: a message that transfer control from the sender to the recipient without describing the details of the communication.
Asynchronous message: a message in which the sender does not have to wait for the recipient to handle the message.
Sequence Diagrams (Cont.)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 8
Scenario modelled: Class registration. Assumptions: course has no prerequisites
1. Registration Clerk opens the registration window and enters the registration information
2. Check if the class is open
3. If the class is open, check if the course has any prerequisites.
4. Assumed course has no prerequisites. Register the student for the class; increment the class size by one.
5. Check if the class ifs full; if not, do nothing
6. Display the confirmed registration in the registration window
Sequence Diagrams (Cont.)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 9Sequence diagram for a class registration scenario without prerequisites
ObjectName:ClassName ‘Non-persistent’
(control) object
Lifeline
No response shown. (assumption: class open)
Guard conditions
‘Self delegation’ (call upon one’s own operation(s)
(Object destroys itself)
Activation (performs operation) Synchronous
message(all shown are synchronous)
AnonymousObject
Named Object (‘a New Registration’)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 10
Scenario modelled: Class registration. Assumptions: course has prerequisites, class not full
1. Registration Clerk opens the registration window and enters the registration information
2. Check if the class is open
3. If the class is open, check if the course has any prerequisites. Assumed course has prerequisites.
4. If the student has taken the prerequisites, then register the student for the class and increment the class size by one.
5. Check if the class ifs full; assumed class not full.
6. Display the confirmed registration in the registration window
Sequence Diagrams (Cont.)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 11Sequence diagram for a class registration scenario with prerequisites
Guard condition for existing prerequisites
In this scenario, assume class not full
Time
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 12A sequence diagram for “Prerequisite Courses Not Completed” use case
Student has not taken prerequisites
Scenario:
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 13
Process Modelling: Activity Diagrams
Elements of Activity Diagrams: Activity: a behavior that an object carries
out while in a particular state. Transition: a movement from one activity
or state to another. Branch: a diamond symbol containing a
condition whose results provide transitions to different paths of activities.
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 14
Activity Diagram for a Customer Order Process
Time
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 15
Process Modelling: Activity Diagrams (Cont.)
Synchronization bar: horizontal or vertical bars denoting parallel or concurrent paths of activities. Fork: the beginning of parallel activities. Join: the end of parallel activities.
Swimlanes: columns representing different organisational units of the system.
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 16
Process Modelling: Activity Diags (Cont.)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 17
Process Modelling: Activity Diags (Cont.)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 18 Hospital Pharmacy Level-0 DFD
2.0
Review Prescription
Order by Station
3.0
Fill Order
4.0
Generate Label
Nurses Station
Doctor
Billing Dept
D1
Patient File
Prescription
Unfilled Order Info
Unfilled Order
Info Response
Order Info
Patient Number
and Drug Type,
Amount & Cost
PharmacyTech ReviewPrescription
Prescription
Ord
er F
ill In
fo
1.0
Review & Send
Prescription to Station
Drug Label Info
Drug Label Info
Patie
nt In
fo
Comparing Activity Diagrams with DFDs
Processes are shown in both diagrams. HOWEVER…
-No time dimension, hence no synchronisation, etc features-No explicit decision logic (remember how it can besuggested in DFDs ??
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 19
Relationship of OO techniques / diagrams
Source: (Satzinger et. al, 2008)
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 20
Summary In this appendix you had the
opportunity to learn how to: Understand how to detail use cases and
represent some system logic with sequence diagrams.
Understand how to represent system logic with activity diagrams.
Understand the relationship between different types of diagrams
© 2008 Prentice Hall, Ovidiu NoranLecture 7b 21
References Fowler, M. 2000. UML Distilled: A Brief
Guide to the Object Modelling Language. 2nd Ed. Reading, MA: Addison Wesley
Satzinger, G., Jackson, R.Burd, S. 2008. Systems Analysis and Design in a Changing World. 5th Ed. Course Technology