SlideShare una empresa de Scribd logo
1 de 26
By
            Nadeem Mahmood
Department of Computer Science
         University Of Karachi
Interaction Diagrams


Interaction diagrams describe exemplary how
 groups of objects collaborate in some behavior.
An interaction diagram typically captures the
 behavior of a single use case.
Interaction diagrams do not capture the complete
 behavior, only typical scenarios.
Types of Interaction Diagrams
 There are two types of interaction diagrams:
Sequence diagrams emphasize the order or
 concurrency of the interactions.
Collaboration diagrams emphasize the interacting
 objects.
Behavior of the “order” use case:
A customer orders several products.
The (sub-)orders (“order lines”) for each product are prepared
separately.
For each product check the stock.
• If the product is in stock, remove requested amount from stock.
• If the product stock falls below a predefined level, reorder it.
Object
Object naming:
   syntax: [instanceName][:className]
                                                         myBirthdy
                                                           :Date
   Name classes consistently with your class diagram
    (same classes).
   Include instance names when objects are referred
    to in messages or when several objects of the same
    type exist in the diagram.
The Life-Line represents the object’s life
 during the interaction
Messages
An interaction between two objects is performed as
 a message sent from one object to another (simple
 operation call, Signaling, RPC)
If object obj1 sends a message to another object obj2
 some link must exist between those two objects
 (dependency, same objects)
Messages (Cont.)
A message is represented by an arrow between the
 life lines of two objects.
   Self calls are also allowed
   The time required by the receiver object to process the
    message is denoted by an activation-box.
A message is labeled at minimum with the message
 name.
   Arguments and control information (conditions, iteration)
    may be included.
Return Values
Optionally indicated using a dashed arrow with a
 label indicating the return value.
  Don’t model a return value when it is obvious what is
   being returned, e.g. getTotal()
  Model a return value only when you need to refer to it
   elsewhere, e.g. as a parameter passed in another
   message.
  Prefer modeling return values as part of a method
   invocation, e.g. ok = isValid()
Synchronous Messages
Nested flow of control, typically implemented as an
 operation call.
  The routine that handles the message is completed
    before the caller resumes execution.


                   :A                       :B

                        doYouUnderstand()

                                                   return
   Caller
                              yes                (optional)
  Blocked
Object Creation
An object may create another object via a
 <<create>> message.


                                            Preferred
      :A                  :B   :A

           <<create>>               <<create>>
                                                 :B


            Constructor
Object Destruction
An object may destroy another object via a
 <<destroy>> message.
   An object may destroy itself.
   Avoid modeling object destruction unless memory
    management is critical.


                                    :A             :B
                                         <<destroy>>
Why not just code it?
 Sequence diagrams can be somewhat close to the code
     level. So why not just code up that algorithm rather than
     drawing it as a sequence diagram?
    a good sequence diagram is still a bit above the level of the real code (not
     EVERY line of code is drawn on diagram)
    sequence diagrams are language-agnostic (can be implemented in many
     different languages
    non-coders can do sequence diagrams
    easier to do sequence diagrams as a team
    can see many objects/classes at a time on same page (visual bandwidth)




17
Lifetime of objects
creation: arrow with 'new'
 written above it
  notice that an object created
       after the start of the scenario
       appears lower than the
       others

deletion: an X at bottom of
 object's lifeline
  Java doesn't explicitly delete
       objects; they fall out of scope
       and are garbage-collected



  18
Indicating selection and loops
frame: box around part of a sequence diagram to
     indicate selection or loop
     if -> (opt) [condition]
     if/else -> (alt) [condition], separated by horiz. dashed
      line
     loop -> (loop) [condition or items to loop over]
                                opt   [balance 0]
                                             <>                alt      [balance 100 ]
                                                                               < .00


                                                                     [balance 100 ]
                                                                            >= .00




                                                loop   [balance 0]
                                                              <




19
Reference: Object-Oriented Analysis and Design
J.W. Schmidt, F. Matthes, TU Hamburg-Harburg
Reference: Object-Oriented Analysis and Design
J.W. Schmidt, F. Matthes, TU Hamburg-Harburg
Sequence diag. from use case




26

Más contenido relacionado

La actualidad más candente

Lecture#08 sequence diagrams
Lecture#08 sequence diagramsLecture#08 sequence diagrams
Lecture#08 sequence diagrams
babak danyal
 
Slide 4 Interaction Diagram
Slide 4 Interaction DiagramSlide 4 Interaction Diagram
Slide 4 Interaction Diagram
Niloy Rocker
 
Software Quality Attributes
Software Quality AttributesSoftware Quality Attributes
Software Quality Attributes
Hayim Makabee
 

La actualidad más candente (20)

Lecture#08 sequence diagrams
Lecture#08 sequence diagramsLecture#08 sequence diagrams
Lecture#08 sequence diagrams
 
Activity diagram-UML diagram
Activity diagram-UML diagramActivity diagram-UML diagram
Activity diagram-UML diagram
 
Sequence Diagram
Sequence DiagramSequence Diagram
Sequence Diagram
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
Uml class-diagram
Uml class-diagramUml class-diagram
Uml class-diagram
 
Slide 4 Interaction Diagram
Slide 4 Interaction DiagramSlide 4 Interaction Diagram
Slide 4 Interaction Diagram
 
system sequence diagram
system sequence diagramsystem sequence diagram
system sequence diagram
 
UNIFIED MODELING LANGUAGE
UNIFIED MODELING LANGUAGEUNIFIED MODELING LANGUAGE
UNIFIED MODELING LANGUAGE
 
Class diagrams
Class diagramsClass diagrams
Class diagrams
 
The Ultimate Sequence Diagram Tutorial
The Ultimate Sequence Diagram TutorialThe Ultimate Sequence Diagram Tutorial
The Ultimate Sequence Diagram Tutorial
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
 
Object diagram
Object diagramObject diagram
Object diagram
 
Lecture11 use case sequence diagram
Lecture11 use case sequence diagramLecture11 use case sequence diagram
Lecture11 use case sequence diagram
 
Software Quality Attributes
Software Quality AttributesSoftware Quality Attributes
Software Quality Attributes
 
Sequence diagram
Sequence diagramSequence diagram
Sequence diagram
 
Collaboration diagram- UML diagram
Collaboration diagram- UML diagram Collaboration diagram- UML diagram
Collaboration diagram- UML diagram
 
Agile Development | Agile Process Models
Agile Development | Agile Process ModelsAgile Development | Agile Process Models
Agile Development | Agile Process Models
 
UML
UMLUML
UML
 
SE_Lec 09_ UML Behaviour Diagrams
SE_Lec 09_ UML Behaviour DiagramsSE_Lec 09_ UML Behaviour Diagrams
SE_Lec 09_ UML Behaviour Diagrams
 

Similar a Ooad sequence diagram lecture

06 ooad uml-07
06 ooad uml-0706 ooad uml-07
06 ooad uml-07
Niit Care
 
Pertemuan 6-2-sequence-diagram
Pertemuan 6-2-sequence-diagramPertemuan 6-2-sequence-diagram
Pertemuan 6-2-sequence-diagram
Abi Bobon
 

Similar a Ooad sequence diagram lecture (20)

Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
 
Introduction to OOA and UML - Part 2
Introduction to OOA and UML - Part 2 Introduction to OOA and UML - Part 2
Introduction to OOA and UML - Part 2
 
06 ooad uml-07
06 ooad uml-0706 ooad uml-07
06 ooad uml-07
 
Visual basic bt0082
Visual basic  bt0082Visual basic  bt0082
Visual basic bt0082
 
Funtional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWTFuntional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWT
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.
 
Software Engineering Lec 7-uml-
Software Engineering Lec 7-uml-Software Engineering Lec 7-uml-
Software Engineering Lec 7-uml-
 
Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3
 
Pertemuan 6-2-sequence-diagram
Pertemuan 6-2-sequence-diagramPertemuan 6-2-sequence-diagram
Pertemuan 6-2-sequence-diagram
 
Ood Post1
Ood Post1Ood Post1
Ood Post1
 
From Declarative to Imperative Operation Specifications (ER 2007)
From Declarative to Imperative Operation Specifications (ER 2007)From Declarative to Imperative Operation Specifications (ER 2007)
From Declarative to Imperative Operation Specifications (ER 2007)
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6
 
Cpprm
CpprmCpprm
Cpprm
 
Programming in Scala - Lecture Four
Programming in Scala - Lecture FourProgramming in Scala - Lecture Four
Programming in Scala - Lecture Four
 
4. UML
4. UML4. UML
4. UML
 
While writing program in any language, you need to use various variables to s...
While writing program in any language, you need to use various variables to s...While writing program in any language, you need to use various variables to s...
While writing program in any language, you need to use various variables to s...
 
11-Classes.ppt
11-Classes.ppt11-Classes.ppt
11-Classes.ppt
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Algorithms: I
Algorithms: IAlgorithms: I
Algorithms: I
 
Web Design & Development - Session 6
Web Design & Development - Session 6Web Design & Development - Session 6
Web Design & Development - Session 6
 

Más de asimnawaz54

Lecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inferenceLecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inference
asimnawaz54
 
Lecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inferenceLecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inference
asimnawaz54
 
Expert systems with applications
Expert systems with applicationsExpert systems with applications
Expert systems with applications
asimnawaz54
 
Establishing knowledge base
Establishing knowledge baseEstablishing knowledge base
Establishing knowledge base
asimnawaz54
 
Designing the expert system
Designing the expert systemDesigning the expert system
Designing the expert system
asimnawaz54
 
1 s2.0-s0957417410007244-main
1 s2.0-s0957417410007244-main1 s2.0-s0957417410007244-main
1 s2.0-s0957417410007244-main
asimnawaz54
 
Packet switching
Packet switchingPacket switching
Packet switching
asimnawaz54
 
Network layer and circuit switching
Network layer and circuit switchingNetwork layer and circuit switching
Network layer and circuit switching
asimnawaz54
 
Network layer and circuit switching
Network layer and circuit switchingNetwork layer and circuit switching
Network layer and circuit switching
asimnawaz54
 
Internet control message protocol
Internet control message protocolInternet control message protocol
Internet control message protocol
asimnawaz54
 
Address resolution protocol
Address resolution protocolAddress resolution protocol
Address resolution protocol
asimnawaz54
 
Address resolution protocol and internet control message protocol
Address resolution protocol and internet control message protocolAddress resolution protocol and internet control message protocol
Address resolution protocol and internet control message protocol
asimnawaz54
 
Object oriented analysis lab1
Object oriented analysis lab1Object oriented analysis lab1
Object oriented analysis lab1
asimnawaz54
 

Más de asimnawaz54 (17)

Lecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inferenceLecture 3 qualtifed rules of inference
Lecture 3 qualtifed rules of inference
 
Lecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inferenceLecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inference
 
Expert systems with applications
Expert systems with applicationsExpert systems with applications
Expert systems with applications
 
Establishing knowledge base
Establishing knowledge baseEstablishing knowledge base
Establishing knowledge base
 
Designing the expert system
Designing the expert systemDesigning the expert system
Designing the expert system
 
1 s2.0-s0957417410007244-main
1 s2.0-s0957417410007244-main1 s2.0-s0957417410007244-main
1 s2.0-s0957417410007244-main
 
Packet switching
Packet switchingPacket switching
Packet switching
 
Network layer and circuit switching
Network layer and circuit switchingNetwork layer and circuit switching
Network layer and circuit switching
 
Network layer and circuit switching
Network layer and circuit switchingNetwork layer and circuit switching
Network layer and circuit switching
 
Ipv6up
Ipv6upIpv6up
Ipv6up
 
Ipv4
Ipv4Ipv4
Ipv4
 
Internet control message protocol
Internet control message protocolInternet control message protocol
Internet control message protocol
 
Address resolution protocol
Address resolution protocolAddress resolution protocol
Address resolution protocol
 
Address resolution protocol and internet control message protocol
Address resolution protocol and internet control message protocolAddress resolution protocol and internet control message protocol
Address resolution protocol and internet control message protocol
 
Requirements analysis
Requirements analysisRequirements analysis
Requirements analysis
 
Advanced software engineering lab 2
Advanced software engineering lab 2Advanced software engineering lab 2
Advanced software engineering lab 2
 
Object oriented analysis lab1
Object oriented analysis lab1Object oriented analysis lab1
Object oriented analysis lab1
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 

Ooad sequence diagram lecture

  • 1. By Nadeem Mahmood Department of Computer Science University Of Karachi
  • 2. Interaction Diagrams Interaction diagrams describe exemplary how groups of objects collaborate in some behavior. An interaction diagram typically captures the behavior of a single use case. Interaction diagrams do not capture the complete behavior, only typical scenarios.
  • 3. Types of Interaction Diagrams There are two types of interaction diagrams: Sequence diagrams emphasize the order or concurrency of the interactions. Collaboration diagrams emphasize the interacting objects.
  • 4.
  • 5. Behavior of the “order” use case: A customer orders several products. The (sub-)orders (“order lines”) for each product are prepared separately. For each product check the stock. • If the product is in stock, remove requested amount from stock. • If the product stock falls below a predefined level, reorder it.
  • 6. Object Object naming:  syntax: [instanceName][:className] myBirthdy :Date  Name classes consistently with your class diagram (same classes).  Include instance names when objects are referred to in messages or when several objects of the same type exist in the diagram. The Life-Line represents the object’s life during the interaction
  • 7. Messages An interaction between two objects is performed as a message sent from one object to another (simple operation call, Signaling, RPC) If object obj1 sends a message to another object obj2 some link must exist between those two objects (dependency, same objects)
  • 8. Messages (Cont.) A message is represented by an arrow between the life lines of two objects.  Self calls are also allowed  The time required by the receiver object to process the message is denoted by an activation-box. A message is labeled at minimum with the message name.  Arguments and control information (conditions, iteration) may be included.
  • 9. Return Values Optionally indicated using a dashed arrow with a label indicating the return value. Don’t model a return value when it is obvious what is being returned, e.g. getTotal() Model a return value only when you need to refer to it elsewhere, e.g. as a parameter passed in another message. Prefer modeling return values as part of a method invocation, e.g. ok = isValid()
  • 10. Synchronous Messages Nested flow of control, typically implemented as an operation call. The routine that handles the message is completed before the caller resumes execution. :A :B doYouUnderstand() return Caller yes (optional) Blocked
  • 11. Object Creation An object may create another object via a <<create>> message. Preferred :A :B :A <<create>> <<create>> :B Constructor
  • 12. Object Destruction An object may destroy another object via a <<destroy>> message.  An object may destroy itself.  Avoid modeling object destruction unless memory management is critical. :A :B <<destroy>>
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. Why not just code it? Sequence diagrams can be somewhat close to the code level. So why not just code up that algorithm rather than drawing it as a sequence diagram?  a good sequence diagram is still a bit above the level of the real code (not EVERY line of code is drawn on diagram)  sequence diagrams are language-agnostic (can be implemented in many different languages  non-coders can do sequence diagrams  easier to do sequence diagrams as a team  can see many objects/classes at a time on same page (visual bandwidth) 17
  • 18. Lifetime of objects creation: arrow with 'new' written above it notice that an object created after the start of the scenario appears lower than the others deletion: an X at bottom of object's lifeline Java doesn't explicitly delete objects; they fall out of scope and are garbage-collected 18
  • 19. Indicating selection and loops frame: box around part of a sequence diagram to indicate selection or loop if -> (opt) [condition] if/else -> (alt) [condition], separated by horiz. dashed line loop -> (loop) [condition or items to loop over] opt [balance 0] <> alt [balance 100 ] < .00 [balance 100 ] >= .00 loop [balance 0] < 19
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. Reference: Object-Oriented Analysis and Design J.W. Schmidt, F. Matthes, TU Hamburg-Harburg
  • 25. Reference: Object-Oriented Analysis and Design J.W. Schmidt, F. Matthes, TU Hamburg-Harburg
  • 26. Sequence diag. from use case 26