Interaction Design & UML Sequence Diagram

Slides:



Advertisements
Similar presentations
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Advertisements

COMMUNICATING SEQUENTIAL PROCESSES C. A. R. Hoare The Queen’s University Belfast, North Ireland.
Software Engineering Design Analysis
Object-Oriented Analysis and Design CHAPTERS 15: UML INTERACTION DIAGRAMS 1.
Software Design Process A Process is a set of related and (sequenced) tasks that transforms a set of input to a set of output. Inputs Outputs Design Process.
Ana M. Fernández  A UML diagram that depicts: ◦ interactions between objects. ◦ how the business currently works by showing how various.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
Summary Class responsibility cards can be used to help allocate responsibilities between different classes. The use of stereotype classes, such as entity,
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
1 © Wolfgang Pelz UML2 UML Part Two. 2 © Wolfgang Pelz UML2 Chapters Four & Twelve Interaction Diagrams.
Essentials of interaction diagrams Lecture 23 & 24.
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Essentials of interaction diagrams Lecture Outline Collaborations Interaction on collaboration diagrams Sequence diagrams Messages from an object.
Chapter 15 Interaction Diagrams. Most Common Sequence Diagram Communication Diagram Sequence Diagrams illustrate interactions between classes of a program.
© 2005 Prentice Hall4-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Sequence Diagrams By Zvika Gutterman Adam Carmi. Agenda Interaction Diagrams A First Look at Sequence Diagrams Objects Messages Control Information Examples.
Objectives Explain the purpose and objectives of object- oriented design Develop design class diagrams Develop interaction diagrams based on the principles.
SE-565 Software System Requirements More UML Diagrams.
Software Design Processes and Management
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Interaction Design Process and Heuristics.
Relationships. In the Interaction diagrams, we began to look at how classes communicate with one another. Now, we'll focus on the relationships between.
SENG 403 SENG 403 – Winter  Brief introduction to SSD  Example (A sales systems (Cashier))  Example (Monopoly game) SENG 403 – Winter 2012.
Karolina Muszyńska Based on: S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”
Sequence Diagram Tutorial
CS3773 Software Engineering
UML Collaboration Diagram. Recap System Sequence Diagrams (SSD) UML for SSD Examples.
מידול התנהגותי 1. Today’s Session Sequence Diagrams State Machines 2.
Interaction diagrams Sequence and collaboration diagrams.
UML / UML 2.0 Diagrams (Part III) 1. Sequence diagram is the most common kind of interaction diagram. It focuses on the message interchange between a.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Introduction to Interaction Diagrams Used to illustrate the dynamic behaviour of a community of objects that collaborate by passing messages in order to.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 9: Interaction.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML Sequence Diagrams.
Chapter 4: UML Interaction Diagrams. Objective Provide a reference for frequently used UML interaction diagram notation- sequence and communication diagrams.
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
Engineering 5895: Software Design 10/5/01Interaction Diagrams1 Modeling Behaviour Engineering 5895: Software Design.
Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Interaction and Communication Diagrams Patrick Bailey Keith Vander Linden Calvin College.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
 C-style pointer-based arrays  Have great potential for errors and several shortcomings  C++ does not check whether subscripts fall outside the range.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour UML Sequence Diagram.
Object-Oriented Analysis and Design 1 Mira Balaban & Arnon Sturm Object-Oriented Analysis and Design Session 3a: Behavioral Modeling - Interactions.
Use Case Driven Analysis Requirements Use Case Use Case Description System Sequence Diagram Chapter 5.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Karolina Muszyńska Based on: S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part VI: Design Continuous Activity Diagams State Diagrams.
Interaction Diagram An interaction diagram is a graphical representation of interactions between objects. Sequence diagram: shows the sequence in which.
Observations so far…. In general… There are two ways to design a software system –Centralized control One “driver” function that contains the entire algorithm.
Chapter 3: Introducing the UML
Sequence Diagram SAD ::: Fall 2015 Sabbir Muhammad Saleh.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
1 Kyung Hee University Interaction Diagrams Spring 2001.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 7 Using Methods.
1 Object Oriented Analysis System modeling = Functional modeling + Object modeling + Dynamic modeling Functional modeling = Use cases Object modeling =class.
Project 2: Phase 1 Submission 7 Late submissions 10% 10 No submissions 14% Better than project 1 phase 3 submissions 10-point bonus: If you catch the deadline.
Sequence diagrams Lecture 5. Main terms  Interaction  Life line  Activation  Executable behavior and derived behavior  Messages  Trajectory  Frame.
Systems Analysis and Design in a Changing World, Fourth Edition
Chapter 11: Collaboration Diagram - PART1
Prepared By Sidra Noureen
Sequence Diagram.
UML Sequence Diagrams.
Princess Nourah bint Abdulrahman University
System Sequence Diagrams
Unified Modelling Language
Chapter 9: Sequence Diagrams Chapter 5 in Software Engineering Book
Interaction diagrams Interaction diagrams are models that describe how groups of objects collaborate in some behavior. Typically, an interaction diagram.
UML Interaction diagrams
Presentation transcript:

Interaction Design & UML Sequence Diagram Once we have decomposed the system and designed the individual components (or classes), we need to depict how these pieces collaborate to deliver the services. (of course, you may go back and re-design the components after looking at the collaboration) The interactions among the individual participants (classes) can be captured with different UML notations, but mainly through Sequence Diagrams Sequence diagram depicts the “message flow” among the participants and thus depicts the collaboration among the participants.

General Sequence Diagram It is composed of a diagram frame: 1) with an identifier name 2) the individual participants (classes) in the form of “lifeline” composed of: A rectangle depicting the participating object A dotted line that extends for the time period of the interaction 3) messages to communicate among the participants order process client order inventory create Locate item

Message Arrows for Communications The message arrows represent the communications between two objects in a sequence diagram. It goes from the lifeline of one object to that of another object Synchronous message where the sending object suspends action and waits for the response to the message Asynchronous message where the sending object continues with its operations without waiting for the response A return of control from the synchronous message A creation of a new entity (filled head) (open head)

Message Specification Every synchronous and asynchronous arrow must be labeled with a message specification on top of the message arrow. The message format : return_variable_name = message_name (param_list) Both the i) return_variable_name and ii) the “=“ sign are suppressed if there is no return value message_name is never suppressed (required field) param_list is a list of arguments separated by commas and is suppressed when there is no argument See page 364 for details of param list

Examples of Sequence Diagram’s message specification age = getAge or age = getAge( ) message specifies that the return value from getAge operation is assigned to the variable age. Note that age is a variable accessible by the object that sent the message checkStatus (flag = status, machine) message specifies that checkStatus operation passes a parameter and gets back the status information which assigned to a “local” variable, flag. (local meaning the object that sent the message)

Execution Occurrence in Sequence Diagram An operation is executing when a process is running An operation is suspended when it sends a synchronous message and waiting for a return message. An operation is considered active when it is either executing or suspended An object is active if one or more of its operation is active. While an object is active it is shown with an execution occurrence (a thin rectangle covering the dashed line). A synchronous message always initiates a new execution occurrence (e.g. Order in the diagram) sample client order inventory create(ord#) locate_item(i)

Interaction Fragments Sequence diagram depicts the interactions among the entities. The natural flow of “control” in the diagram is sequential from top to bottom and follows the direction of the message arrows. The natural sequential control can be broadened with “Interaction Fragments”: Optional Fragment ( “if –then” ) Alternative Fragment ( “if-then-else-if - - -” or “case” ) Break Fragment ( “break” ) Loop Fragment ( iterations or “loop” ) Note that these fragments are like the control structures that exist in a programming language.

Depicting a Fragment Graphically sd sample client order inventory Interaction Fragment create operator op1 Interaction Fragment Operation Name: (e.g. loop) Interaction Fragment Operand Locate item

Depicting an Optional Fragment sd sample client order inventory Interaction Fragment Interaction Fragment Operation Name: (optional) Opt [new_cust] cr_custinfo() Interaction Fragment guard create_order locate_item Interaction Fragment Operand This Optional Fragment has only 1 operand and guard in brackets. A guard is a Boolean expression. The Optional Fragment is performed if the guard is true at that point of the interaction. It is like the “if” structure of programming language

Depicting an Alternative Fragment sd sample client order inventory Interaction Fragment Interaction Fragment Operation Name: (Alternative) Alt [new_cust=yes] cr_custinfo() Interaction Fragment guard [new_cust= no] get_custinfo() Cr_order( ) Interaction Fragment Operands The Alternative Fragment has multiple mutually exclusive guards in brackets. The operand associated with the true guard is executed. This structure is like the “CASE” or “if-then-else-if” constructs of the programming language

Depicting an Break Fragment sd sample client order inventory Interaction Fragment Operation Name: (Break) break [ ! good_status] error_msg( ) Alt [new_cust=yes] cr_custinfo() The guard expression of NOT good_status [new_cust= no] get_custinfo() Cr_order( ) The Break Fragment has a single operand which is processed if the guard is “true,” and the rest of the processing in the diagram is not performed. It is like the “break” construct in programming language.

Depicting an Loop Fragment sd sample order inventory n_it = check_items() checking for more items Interaction Fragment Operation Name: Loop (min,max) create iterator more = has_item (n_it) Loop [more] Process_item() The guard expression of [ more] more = has_item(n_it) The Loop Fragment is expressed as Loop(min,max). The loop is performed at least min times and at most max times. If neither min or max is specified, then min=0 and max is unlimited. If the loop is performed min times but less than max, then it is performed again as long as the guard is true. The default value of guard is true.

Some Sequence Diagram Guidelines Pick a design level (based on the classes in the static model) and “be consistent” at that level through out the interaction diagram. Put the sender of the first message leftmost Put pairs of entities that interact heavily next to each other Position the entities to shorten the message arrows Position the entities to make the message arrows go from let to right Suppress return arrows as much as possible when using execution occurrences

Some Thoughts on Designing Design is not a sequential process but much more iterative: (“Component/Interaction” Co-Design) Design (generate) the components in terms of entities (with class model and express in class diagram) Design the interactions among the classes (express in sequence diagram) Design is not a single level process, but more top-down: (Outside-In Design) Top may be viewed as external (requirement level) Down may be viewed class model and interactions representing deeper levels of solutions Iterate the above as we evaluate, alter, and improve the model (See pages 376 -380 example in your book) And we progressively move into more details (inwards)

Some details on evaluating interaction alternatives (Example) waterHeatercntrl is constantly polling the clock with a fixed rate. - - - efficient for waterHeatercntrl? clock is constantly checking time and notifies waterHeatercntrl when the time arrives, then waterHeatercntrl takes action. SD polling SD notification clock waterHeatercntrl waterHeatercntrl clock loop notify loop time=getTime time=getTime opt opt [time = right] [time = right] takeAction takeAction Which one would you pick and why ? Also, note the synchronous message creates an execution occurrence

On Control Mechanism In designing, one of the issue is on “point of control,” or the controller, which makes decisions and directs other components. There are three major ways to establish control: Centralized control where all decisions are made by one or two entities and the rest of the entities receives directions from them Delegated control where only the main decisions are made by one or two “main” entities, other decisions are delegated to lower level entities and coordinated among the entities. Dispersed control where decision making is spread out widely, with no easily identifiable coordinating entity or entities.

Centralized Control Should be used only when the solution is small and only a few decisions are involved. (easy to find control point) Lots of drawbacks: Centralized control can be “bloated” and too big to manage May be less cohesion when too many varieties of decisions are being made May increase coupling between the controller and other entities which merely act as data store or simple functions Information hiding can NOT be easily achieved Central contrl

Heuristics to Avoid Centralized Control Avoid interaction design where most messages originate from single component Keep components small so that there can not be a “bloated” controller. (This is not very different from the traditional advise on keeping modules small - - - how small is small? --- cohesion?) Make sure that operational responsibilities are not assigned to just a few components. Make sure operational responsibilities are consistent with data responsibilities. (what happens if they are not? - - - you may have less cohesion among methods in a class ) Look at diagram 12-3-3 on page 386: it is an over-centralized control design: - AutoCycle delegates nothing and is coupled with all other objects - it lacks cohesion in that it is doing all types of details - it is too big in size because it contains all the low level activities

Delegated Control Control is in more entities – smaller in size Information hiding is easier with different control points Increased cohesion with delegated points of control Each controller is coupled to less entities. (but over-all # of couplings may not decrease) (Note: the 1st to 4th object interaction is asynchronous) Delegated contrl

Heuristics for Delegated Control Delegated control is the ideal case we are after. Ensure that each component is responsible for “high level” tasks and as much of the lower ( more detailed, less functional, just different functional areas, etc.) level tasks are delegated as possible. The lower level tasks may be performed in a more collaborative manner among several other components. Look at diagram 12-3-4 on page 387, where AutoCycle delegates some responsibilities to Zone. This is a much less coupled and a more cohesive design along with a certain amount of encapsulation of information.

Dispersed Control Too many controls and hard to figure out the interactions: Too much interactions among the entities – high coupling among the parts and possibly very low cohesion within each entity.

Heuristics for avoiding Dispersed control Basically, avoid situations where every component is sending a lot of messages to other components. Ensure that there is not an over-delegation, where each component is responsible for too a small portion of the whole and there are a lot of components involved in accomplishing anything.

Control and Communications centralized & wheel dispersed & all-member delegated & hierarchical [(n x (n-1))/ 2] potential coupling (n-1) potential coupling but deceiving because - -? (n-1) potential coupling but deceiving because - -?

Law of Demeter for OO Interaction Design An operation (method M) of an object, Obj, should send messages only to the following: Within the object, Obj, itself Methods within Obj Attributes of Obj (its instance variables) Argument of the operation (parameters of method M, which may be some object) Elements of a collection that is an argument of the operation or an attribute of the object, Obj. Objects created within the operation (objects instantiated within the method M) Global Classes or objects Note that objects that are returned by messages sent to other object is not included. “ Talk only to your immediate neighbors” The Law of Demeter is meant to help in : (1) information hiding; (2) lessening centralized control

Example from page 375 of text Design a water heater controller based on: Caldera is a smart water heater controller that attaches to the thermostat of a water heater and provides more efficient control of water temperature to save money and protects the environment. Caldera sets the water heater thermostat high when hot water is much in demand and sets it low when there is no much demand. For example: Caldera can be told to set the thermostat high on weekday mornings and evenings and all day on weekends. And low during the middle of the week days and nights. Caldera can be told to set the thermostat high all the time in case of illness or other needs. Caldera can be told to set the thermostat low all the time in case of vacation or some other prolonged absence from house.

Your Caldera Design may progress as follows: heaterController thermostat set_temp 1. Class Model sd Caldera heaterController thermostat 2. Class Interactions set_temp( )

Your Caldera Class Design (further Refinement) ? heaterController thermostat set_temp notify_time special_set notify_date clock manual calendar 3. Further “Refined” Class Model

Your Caldera Interaction Design (further Refinement) ? sd Caldera heaterController thermostat Calendar Clock manual Notify_date( ) Set_temp( ) Notify_time( ) Special_set( ) Set_temp( ) 4. Refined Class Interactions in Sequence Diagram

Further Evaluate and Improve the Caldera Design Consider the notion of adding another entity to represent the notion of “load scaling” or “temp scaling” which traps the inputs from clock and calendar and sends the controller a binary high or low signal. Consider the manual override to go directly to thermostat and be equal to the controller. Draw the Class diagram and the Sequence diagram for these concepts, evaluate and see if they are indeed improvements: - cohesion - coupling - size