Sequence Diagrams and Collaboration Diagrams

Slides:



Advertisements
Similar presentations
1 Inheritance Classes and Subclasses Or Extending a Class.
Advertisements

UML and Classes, Objects and Relationships [1]
Use Case Diagrams.
Network Programming and Java Sockets
© 2005 by Prentice Hall Appendix 3 Object-Oriented Analysis and Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Chapter 7 System Models.
Chapter 7 Constructors and Other Tools. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 7-2 Learning Objectives Constructors Definitions.
Chapter 6 Structures and Classes. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 6-2 Learning Objectives Structures Structure types Structures.
Copyright © 2003 Pearson Education, Inc. Slide 1.
Chapter 1 The Study of Body Function Image PowerPoint
Processes and Operating Systems
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 1 Embedded Computing.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 3 CPUs.
1 Hyades Command Routing Message flow and data translation.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 11: Structure and Union Types Problem Solving & Program Design.
Chapter 3: Top-Down Design with Functions Problem Solving & Program Design in C Sixth Edition By Jeri R. Hanly & Elliot B. Koffman.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Exit a Customer Chapter 8. Exit a Customer 8-2 Objectives Perform exit summary process consisting of the following steps: Review service records Close.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Year 6 mental test 10 second questions
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Week 2 The Object-Oriented Approach to Requirements
Requirements Diagrams With UML Models
OOAD – Dr. A. Alghamdi Mastering Object-Oriented Analysis and Design with UML Module 3: Requirements Overview Module 3 - Requirements Overview.
ITEC200 Week04 Lists and the Collection Interface.
ABC Technology Project
By Waqas Over the many years the people have studied software-development approaches to figure out which approaches are quickest, cheapest, most.
Use Case Diagrams.
1 Undirected Breadth First Search F A BCG DE H 2 F A BCG DE H Queue: A get Undiscovered Fringe Finished Active 0 distance from A visit(A)
VOORBLAD.
1 Breadth First Search s s Undiscovered Discovered Finished Queue: s Top of queue 2 1 Shortest path from s.
1 public class Newton { public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t)
BIOLOGY AUGUST 2013 OPENING ASSIGNMENTS. AUGUST 7, 2013  Question goes here!
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
4 Oracle Data Integrator First Project – Simple Transformations: One source, one target 3-1.
© 2012 National Heart Foundation of Australia. Slide 2.
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
آزمایشگاه مهندسی نرم افزار
Executional Architecture
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
25 seconds left…...
H to shape fully developed personality to shape fully developed personality for successful application in life for successful.
Januar MDMDFSSMDMDFSSS
Chapter 10: The Traditional Approach to Design
Systems Analysis and Design in a Changing World, Fifth Edition
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Intracellular Compartments and Transport
PSSA Preparation.
Chapter 11 Component-Level Design
Essential Cell Biology
Abstract Class, Packages and interface from Chapter 9
1 Abstract Class and Packages from Chapter 9 Lecture.
Modeling Main issues: What do we want to build How do we write this down.
From Model-based to Model-driven Design of User Interfaces.
Chapter 9: Using Classes and Objects. Understanding Class Concepts Types of classes – Classes that are only application programs with a Main() method.
SE-565 Software System Requirements More UML Diagrams.
UML Collaboration Diagram. Recap System Sequence Diagrams (SSD) UML for SSD Examples.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
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 Getting the Message.
Presentation transcript:

Sequence Diagrams and Collaboration Diagrams Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software Engineering University of Melbourne, Australia http://www.cs.mu.oz.au/~raj or http://www.buyya.com

Introduction/Agenda Pieces of UML: Learned so far: Structural Diagrams Class and object diagram Component and Deployment Diagram Behavioural Diagrams Use Case Diagram Activity Diagram Sequence Diagram Collaboration Diagram State Chart Diagram Learned so far: Use case diagram, class and object diagram, class relationships Today we will focus on:

Object Oriented Design Design consists of the following steps : Refine the class diagram. Draw the interaction diagrams for the system. Sequence Diagram Collaboration Diagram If objects go through complex state transitions – statechart diagrams Do the above steps iteratively as needed.

Sequence Diagram Shows how objects communicate with each other over time. That is, sequence diagrams are used to model object interactions arranged in time sequence and to distribute use case behavior to classes. They can also be used to illustrate all the paths a particular use case can ultimately produce. The sequence diagram consists of Active Objects, Messages represented as solid-line arrows, and Time represented as a vertical progression.

Sequence Diagram - Objects A life line illustrates what is happening to an object in a chronological fashion. :Name Object Life line Activation

Sequence Diagram – Time & Messages Messages are used to illustrate communication between different active objects of a sequence diagram. :Name1 :Name2 Actor Message One Message Two

Types of Messages Synchronous (flow interrupt until the message has completed. Asynchronous (don’t wait for response) Flat – no distinction between sysn/async Return – control flow has returned to the caller.

Sequence Diagram – Compilation :Compiler Linker FileSystem Actor Compile Load Files Compile files Save OBJ Files Link Load OBJ files Link OBJ files Write EXE file

Branching Flow: flow goes to different objects [if condition is met] :Editor FileSystem Load File :BinaryViewer :TextViewer [text file] [binary file]

Alternative Flow: flow changes to alternative lifeline branch of the same object Editor FileSystem Actor Exit App [delete file] [save file]

Sequence diagram -example Use case Add Subject Use Case to URS (University Record System): Scenario Scenario 1 : Subject gets added successfully. Scenario 2 : Adding the subject fails because the subject is already in the database.

System Design Principles System input can take different forms. E.g. From a graphical user interface From a command file URS system should be designed such that the functionality can be re-used. Command reading and functionality implementation have to be separated.

Reading from a command file - example class URS{ public static void main(String[] args){ URSDatabase u = new URSDatabase(); //Read command from file; while ( not end of file) { u.procCommand(cmd); //Read next commad; } //Close file

Sequence Diagram – URS Add Subject Scenario u:URSDatabase procCmd(cmd) parseCommand(cmd) {transient} a:AddSubCmd << create >> [if cmdN = ADDSUB] AddSubCmd(u,cmdA) execute() sub1:Subject Subject(id,name) << create >> addSubject(sub1)

Creating and Deleting objects c:Client p: ODBProxy {transient} <<create>> :Transaction setAction(a, d, 0) setVales(a,d,3,4) committed <<destroy>>

Collaboration Diagrams

Collaboration Diagrams Class diagrams indicates what classes are part of our system, what they offer, how they relate, but they don’t tell us how they communicate. Collaboration diagrams show (used to model) how objects interact and their roles. They are very similar to sequence diagrams. Actually they are considered as a cross between class and sequence diagram. Sequence Diagrams are arranged according to Time. Collaboration Diagrams represent the structural organization of object. [Both sequence and collaboration diagrams are called interaction diagrams] A collaboration diagram can also be considered as an extension of object diagram. In addition to the associations among objects, collaboration diagram shows the messages the objects send each other. Messages among objects are represented with arrows that points to receiving object, near the association line between two objects. Collaboration and sequence diagrams are interchangeable. A label near the arrow shows what the message is. The message  typically tells the receiving object to execute one of its operations. A pair of parentheses ends the message. Parameters are specified within parentheses.

Collaboration Diagram – URS Add Subject Scenario 1:parseCommand(cmd) {transient} <<self>> procCmd(cmd) a:AddSubCmd 2:[if cmdN = ADDSUB] AddSubCmd(u,cmdA) u:URSDatabase {new} 3: execute() <<local>> 3.2: addSubject(sub1) sub1:Subject 3.1: Subject(id,name) {new}

Collaboration Diagram – URS Add Subject Scenario 1:parseCommand(cmd) <<self>> procCommand(cmd) u:URSDatabase class URSDatabase{ private String cmdN; private String cmdA; private parseCommand(String cmd){ cmdN = …. cmdA = …. } public procCommand(String cmd){ parseCommand(cmd);

Collaboration Diagram – URS Add Subject Scenario {transient} a:AddSubCmd u:URSDatabase 2: AddSubCmd(u,cmdA) {new} class URSDatabase{ private String cmdN; private String cmdA; public procCommand(String cmd){ parseCommand(cmd); if (cmdN == ADDSUB){ AddSubCmd a = new AddSubCmd(u,cmdA); }

Collaboration Diagram – URS Add Subject Scenario class abstract Command { protected String cmd; protected URSDatabase u; public abstract void execute(); } class AddSubCmd extends Command{ public AddSubCmd(URSDatabase urs, String cmd){ u = urs; // parse command and set the arguments public void execute(){ // implement here

Collaboration Diagram – URS Add Subject Scenario 3: execute() a:AddSubCmd u:URSDatabase <<local>> class URSDatabase{ private String cmd; public procCommand(String cmd){ parseCommand(0); if (cmd == ADDSUB){ AddSubcmd a = new AddSubCmd(……); } a.execute();

Collaboration Diagram – URS Add Subject Scenario a:AddSubCmd class AddSubCmd{ URSDatabase u; public execute(){ subject sub1 = new Subject(id,name); } sub1:Subject 3.1: Subject(id,name)

Collaboration Diagram – URS Add Subject Scenario a:AddSubCmd u:URSDatabase 3.2: addSubject(sub1) class AddSubCmd{ URSDatabse u; public execute(){ subject sub1 = new Subject(……); u.addSubject(sub1); }

Collaboration Diagram – URS Add Subject Scenario class URSDatabase{ private String cmd; private Hashtable subjectHash = new HashTable(); public procCommand(String cmd){ parseCommand(0); if (cmd == ADDSUB){ AddSubcmd a = new AddSubCmd(……); } a.execute(); public addSubject(Subject sub); { subjectHash.put(sub.getKey(), sub);

URS -High Level Class Diagram URSDatabase 1 1 * has has * UniversityMember Subject 0…10 0..3 AcademicStaff Student * takes 1 teaches

Collaboration Diagrams Collaborations Diagrams show transient links that exists between objects. <<self>> - A message from object to itself << local>> - A message sent due to the object begin defined as a local variable in the method. <<parameter>> - The object reference was sent as a parameter to the method. <<global>> The object is global. A collaboration diagram can also be considered as an extension of object diagram. In addition to the associations among objects, collaboration diagram shows the messages the objects send each other. Messages among objects are represented with arrows that points to receiving object, near the association line between two objects. Collaboration and sequence diagrams are interchangeable. A label near the arrow shows what the message is. The message  typically tells the receiving object to execute one of its operations. A pair of parentheses ends the message. Parameters are specified within parentheses.

Use Case Vs Scenarios Use case Scenario Enroll Subject Use Case: Scenario 1 : Student is enrolled for the subject. Scenario 2 : Enrollment fails since the student is already enrolled in 10 subjects.

Sequence Diagram – Enroll Student for subject successfully stu:Student addSubject(sub) u:URSDatabase procCmd(cmd) parseCommand(cmd) {transient} a:AssgSubCmd << create >> AssgSubCmd(u,cmdA) execute() getStudent(id) return stu getSubject(subId) return sub [if stu != NULL and sub != NULL]

Collaboration Diagram – Enroll Student in Subject Scenario <<self>> 1:parseCommand() {new} a:AssgSubCmd 2:AddSubCmd(u,cmdA) {transient} procCmd(cmd) u:URSDatabase <<local>> 3: execute() 3.1: stu: =getStudent(id) 3.2: sub: = getSubject(subId) stu:Student 3.3: [stu !=NULL and sub!= NULL]: addSubject(sub) {parameter}

Collaboration Diagram – Enroll Student in Subject subject - implementation procCmd(cmd) {transient} {new} u:URSDatabase <<local>> 3: execute() a:AssgSubCmd 3.1: stu: =getStudent(id) 3.2: sub: = getSubject(subId) stu:Student 3.3: [stu !=NULL and sub!= NULL]: addSubject(sub) class AssgSubCmd{ private URSDatabase u; public execute(){ Student stu = u.getStudent(id); Subject sub = u.getSubject(subId); if (stu != null && sub != null){ stu.addSubject(sub); } {parameter}

Sequence Diagram – Enroll Student for subject - Failure u:URSDatabase [if stu != NULL and sub != NULL] stu:Student addSubject(sub) procCmd(cmd) parseCommand() {transient} a:AssgSubCmd << create >> AssgSubCmd(u,cmd) execute() getNumSubjects() return num Excp [num >= 10] return e