SlideShare una empresa de Scribd logo
1 de 58
Modeling Behavior
          Interaction Diagrams
              Activity Diagram
        State Machine Diagram



       OOAD                  1
Learning Objectives
   Understand how to represent system
    logic with interaction diagrams.
   Understand how to represent system
    logic with activity diagram.
   Understand how to represent system
    logic with state machine diagram.


Chapter 8 Appendix         © 2008 by Prentice Hall   2
UML Dynamic Modeling
• In all systems, events happen dynamically,
  e.g.:
  – Objects are created and destroyed
  – Objects send messages to one another
  – External events trigger operations on certain
    objects
• Objects have states that would be difficult to
  capture in a static model
                       OOAD                         3
UML Dynamic Modeling (cont.)
• Behavior diagrams (dynamic):
  – Interaction diagrams
     • Sequence diagrams
     • Collaboration diagrams
  – Statechart diagrams
  – Activity diagrams



                         OOAD    4
Sequence Diagrams: An example




             OOAD           5
Collaboration diagram: An Example




             OOAD                   6
When to use Interaction
           Diagrams?
• Interaction diagrams are used when you want
  to model the behavior of several objects in a
  use case.  They demonstrate how the objects
  collaborate for the behavior. 
• Interaction diagrams do not give a in depth
  representation of the behavior.  If you want
  to see what a specific object is doing for
  several use cases use a state diagram.  To
  see a particular behavior over many use cases
  or threads use an activity diagrams.
                     OOAD                    7
Messages are passed between objects, and
may contain parameters (e.g., message name
(parameter list))
Sequence Diagrams
• Describing the behavior of a system by
  viewing the interaction between the system
  and its environment
• Shows the objects participating in the
  interaction by their life lines and the messages
  they exchange
• Shows an interaction arranged in a time
  sequence
                      OOAD                     9
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.
• Activation: the time period during which an
  object performs an operation.
                     OOAD                       10
Objects/Classes

Client                       ATMMachine                            SavingAccount

          Insert ATM card

           Request PIN

         Enter PIN code
                                            Verify PIN code


                                           PIN valid

         Request amount                                                      activation
         Enter amount

                                            Process transaction


                                          Transaction successful

         Dispense cash

         Print receipt




                              lifeline
Collaboration Diagrams
• Also known as Communication diagrams
• Represents a collaboration, which is a set of objects
  related in a particular context, and interaction, which
  is a set of messages exchanged among the objects
  within the collaboration to achieve a desired
  outcome
• sequences of messages are shown by numbering


                         OOAD                        12
1: insert ATM card
          3: enter PIN code
          7: enter amount
                                                             :ATMMachine


:Client
                  2: request PIN
                  6: request amount
                  10: dispense cash                              4: verify PIN code
                  11: print receipt                              8: process transaction

                      5: valid PIN code
                      9: transaction successful



                                            :SavingAccount
Sequence Vs Collaboration
 Sequence Diagram:
   – Dynamic behavior of a set of objects arranged in time sequence, new
     objects added to the right
   – Good for real-time specifications and complex scenarios
   – easier to read
 Collaboration Diagram :
   – Shows the relationship among objects.
   – Does not show time
   – Objects are arranged in a graph or network format
• Both are used to examine the behavior of objects
  within a single use case

                                OOAD                                14
How to draw sequence diagram?




                                9-15
Drawing Sequence Diagrams
 Determine the context of the sequence diagram
 Identify the object that are participate in the
  sequence
 Set of the lifeline for each object
 Lay out of messages from the top to the bottom of
  the diagram based on the order in which they sent
 Add the execution occurrence to each object’s
  lifeline
 Validate the sequence diagram
Identifying Classes/Objects
• Noun phrase approach – read through the
  requirements or use cases looking for noun
  phrases
• Some classes are implicit or taken from
  general knowledge
• Carefully choose and define class names


                     OOAD                      17
Use Case: Withdraw saving
A customer wants to draw money from his bank account.
He enters his card into an ATM (automated teller machine).
The ATM machine prompts “ Enter PIN”. The customer
enters his PIN. The ATM (internally) retrieves the bank
account number from the card. The ATM encrypts the PIN
and the account number and sends it over to the bank. The
bank verifies the encrypted account and PIN number. If the
PIN number is correct, the ATM displays, “Enter Amount”.
Draws money from the bank account and pays out the
amount.

                          OOAD                           18
Use Case: Withdraw saving
Use Case: Withdraw Saving
Actors:           Bank Client

Flow of Events:
5.   Bank client insert ATM card into ATM machine
6.   ATM machine request PIN code
7.   Bank client enter PIN code
8.   Verify PIN code entered with saving account
9.   ATM machine request amount if the PIN is valid
10. Bank client enter the required amount
11. Process the transaction in the client account
12. ATM machine dispense cash
13. ATM machine print receipt when the transaction completed

Alternative Flow of Events
•    Invalid PIN code entered. Indicate error message. Return step 3.

                                           OOAD                         19
Identifying Classes – noun
      phrase approach (example)
• ATM System
  –   Bank Client
  –   ATM Card
  –   ATM Machine
  –   Savings Account
  –   Cash
  –   Message

                        OOAD       20
Client                      ATMMachine                            SavingAccount

          Insert ATM card

           Request PIN

         Enter PIN code
                                           Verify PIN code


                                          PIN valid

         Request amount

         Enter amount

                                           Process transaction


                                         Transaction successful

         Dispense cash

         Print receipt
Another example …




       OOAD         22
ATM System



                 ATM approval



                 Deposit amount
  Client

                Withdraw amount



Use case: ATM approval
2. Insert ATM card
3. Request PIN
4. Enter PIN
5. Verify PIN
6. Display message to client
Client   ATM Machine   ClientDatabase




                                Use case: ATM
                                    approval
                                2. Insert ATM card
                                3. Request PIN
                                4. Enter PIN
                                5. Verify PIN
                                6. Display message to
                                    client
ATM System



                   ATM approval



                   Deposit amount
   Client

                  Withdraw amount



Use case: Withdraw amount
2. Request withdrawal amount
3. Enter withdrawal amount
4. Check account
5. Verify sufficient funds
6. Eject cash
• Object naming
   – Syntax: [objectName]:[className]
   – Include object (instance) names when objects are referred to in messages
     or when several objects of the same type exist in the diagram
   – Name classes consistently with your class diagram




                     Object A: Class A            Object B: Class B
     :User

              messageA()
                                   messageB(“string”)
                                                              messageC()
Stereotypes of Analysis Classes
   Classes or objects can be classified into one
    of the following three stereotypes:
    – Entity – to hold data
    – Boundary – used by actors to interact with the system
      For example: Customer place order, interact using a
      order form.
    – Control – coordinating behavior in the system
      For example: control the activities in the transaction
      (i.e., rules, calculations)
Stereotypes of Analysis Classes

              Is an object relation that is
              extended to include
              responsibilities
Stereotypes of Analysis Classes

              Is an object relation that is
              extended to include
              responsibilities
Stereotypes of Analysis Classes
            A boundary class provides the
            interface between an actor and use
            case. The actor can be a human or an
            external system.

            Encapsulates connections between
            actors and use cases
Stereotypes of Analysis Classes
            A boundary class provides the
            interface between an actor and use
            case. The actor can be a human or an
            external system.

            Encapsulates connections between
            actors and use cases
Stereotypes of Analysis Classes

             A control class coordinates the
             tasks and captures the main
             logic in a use case.

             Mostly performs behaviors
             associated with inner workings
             of use cases
Typically, actors
interact with
boundary
classes, which in
turn interact with
control classes,
which in turn
interact with
entity classes.
Operations
(behaviors) are
depicted in the
lower third of a
class box.

Operations fulfill
the class’s
responsibilities.
Modeling Behavior
              Activity Diagram
                State Diagram




       OOAD                  40
Activity Diagram: An
       example




               OOAD    41
When to use Activity Diagram?
• The main reason to use activity diagrams is
  to model the workflow behind the system
  being designed. 
• Activity Diagrams are also useful for:
  analyzing a use case by describing what
  actions need to take place and when they
  should occur;  describing a complicated
  sequential algorithm;  and modeling
  applications with parallel processes.
                     OOAD                   42
Activity Diagram
Focus on flow of activity of internal process in
 object
similar to flowchart
describe changes in activity in a procedure
information from use case scenario or event flow
 can be used to describe activity diagram.
Used to provide detail for complex algorithms




                       OOAD                         43
Activity Diagram (cont.)
• Purpose:
  – Modeling human task
  – Describe system’s function
  – Describe logic operation
• Elements in activity diagram:
      Activity      Transition    Decision




                     OOAD                    44
Example of Activity Diagram for Register Course
   start




Fill form               Select course

                                         [No]


            Submit to
              PA                                approve?



                                          [Yes]


                                    Register
                                    course                 end
Example of Activity Diagram for ATM Authorization



Enter card         Read card




 Enter PIN        Request PIN
                                         [No]




                   Verify PIN                     valid?


                                          [Yes]


                                  Select other
                                    service
Swimlane
       - partition an activity
       diagram so that parts in the
       swimlane relevant to that
       activities in the partition
       - helpful in investigating
       responsibilities for
       interactions and
       associations between
       objects and actors




OOAD                         47
Activity diagram with
synchronization bars –
split into multiple paths
and multiple paths
combined into a single
transition

Top synchronization bar is
a fork.

Bottom synchronization
bar is a join.




                             OOAD   49
OOAD   50
When to use State Diagram?
• Use state diagrams to demonstrate the
  behavior of an object through many use
  cases of the system. 
• Only use state diagrams for classes
  where it is necessary to understand the
  behavior of the object through the
  entire system

                  OOAD                51
What is a State Diagram?
• A diagram that captures the behavior of an object by
  specifying the sequence of states it goes through during
  its lifetime in response to events, together with the
  responses to those events
• describe changes in state in a procedure
• Also called statechart diagram or state machine diagram
• State – a condition or situation during the life of an
  object at which time it satisfies some condition, performs
  some activity, or waits for some event.



                          OOAD                          52
What is a State Diagram? (cont.)
• A state diagram to describe the behavior (i.e., state
  changes) of a single class according to events and
  messages which class sends and receives
• A state diagram can also clarify a use case – to
  specify the actions the use case can take in
  accordance with varying conditions of the system
• E.g., a use case ‘enroll course’, the state can be full,
  opened, and closed.



                          OOAD                         53
State Diagram Example

Invoice created
                                              Invoice destroyed
                              Paying
                  Unpaid               Paid
Transition Notation


                State 1 Event(parameters) [condition] /action   State 2
              do/activity 1                                       ...




      Start state                       transition                  End state

Example: Event(parameters) [condition]

mouse_button_clicked(right_button)[inside the window]

Example: /action

/calculate amount
State Notation
                           Name compartment




           Action labels




    OOAD                                      56
Recap
• After studying this chapter we learned to:
  – Understand how to structure requirements with
    interaction diagram, activity diagram and state
    machine diagram.
  – Explain the element of sequence diagrams,
    activity diagram and state machine diagram.
  – Construct sequence diagrams, activity diagram
    and state machine diagram

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Domain Modeling
Domain ModelingDomain Modeling
Domain Modeling
 
Lecture6 activity diagrams
Lecture6 activity diagramsLecture6 activity diagrams
Lecture6 activity diagrams
 
Memory virtualization
Memory virtualizationMemory virtualization
Memory virtualization
 
Use case Diagram and Sequence Diagram
Use case Diagram and Sequence DiagramUse case Diagram and Sequence Diagram
Use case Diagram and Sequence Diagram
 
Unit 4
Unit 4Unit 4
Unit 4
 
Uml - An Overview
Uml - An OverviewUml - An Overview
Uml - An Overview
 
Lecture11 use case sequence diagram
Lecture11 use case sequence diagramLecture11 use case sequence diagram
Lecture11 use case sequence diagram
 
Pram model
Pram modelPram model
Pram model
 
Using Control Flow for Generating Dynamic Content
Using Control Flow for Generating Dynamic ContentUsing Control Flow for Generating Dynamic Content
Using Control Flow for Generating Dynamic Content
 
6.distributed shared memory
6.distributed shared memory6.distributed shared memory
6.distributed shared memory
 
Modeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and FunctionalModeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and Functional
 
Distributed objects
Distributed objectsDistributed objects
Distributed objects
 
CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3
 
state modeling In UML
state modeling In UMLstate modeling In UML
state modeling In UML
 
Use case Diagram
Use case DiagramUse case Diagram
Use case Diagram
 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
 
Distributed DBMS - Unit 6 - Query Processing
Distributed DBMS - Unit 6 - Query ProcessingDistributed DBMS - Unit 6 - Query Processing
Distributed DBMS - Unit 6 - Query Processing
 
Task programming
Task programmingTask programming
Task programming
 
Sequence diagrams
Sequence diagramsSequence diagrams
Sequence diagrams
 
Scripting Languages
Scripting LanguagesScripting Languages
Scripting Languages
 

Similar a Seq uml

Creating an In-Aisle Purchasing System from Scratch
Creating an In-Aisle Purchasing System from ScratchCreating an In-Aisle Purchasing System from Scratch
Creating an In-Aisle Purchasing System from ScratchJonathan LeBlanc
 
[WSO2Con Asia 2018] Patterns for Building Streaming Apps
[WSO2Con Asia 2018] Patterns for Building Streaming Apps[WSO2Con Asia 2018] Patterns for Building Streaming Apps
[WSO2Con Asia 2018] Patterns for Building Streaming AppsWSO2
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingRAJU MAKWANA
 
Use cases - As approach to building shared vision
Use cases - As approach to building shared visionUse cases - As approach to building shared vision
Use cases - As approach to building shared visionAbhilash Gopalakrishnan
 
The atm system
The atm systemThe atm system
The atm systemLê Đức
 
vu-re-lecture-33 requirement engineering.ppt
vu-re-lecture-33 requirement engineering.pptvu-re-lecture-33 requirement engineering.ppt
vu-re-lecture-33 requirement engineering.pptubaidullah75790
 
A Review on Unified Payment Interface [UPI]
A Review on Unified Payment Interface [UPI]A Review on Unified Payment Interface [UPI]
A Review on Unified Payment Interface [UPI]IRJET Journal
 
Open Payments Cloud at Findevr London 2017
Open Payments Cloud at Findevr London 2017Open Payments Cloud at Findevr London 2017
Open Payments Cloud at Findevr London 2017Ixaris Systems
 
Refining The System Definition
Refining The System DefinitionRefining The System Definition
Refining The System DefinitionSandeep Ganji
 
Corda Developer Bootcamp: Accounts
Corda Developer Bootcamp: AccountsCorda Developer Bootcamp: Accounts
Corda Developer Bootcamp: AccountsR3
 

Similar a Seq uml (20)

ATM.pptx
ATM.pptxATM.pptx
ATM.pptx
 
Oops
OopsOops
Oops
 
Creating an In-Aisle Purchasing System from Scratch
Creating an In-Aisle Purchasing System from ScratchCreating an In-Aisle Purchasing System from Scratch
Creating an In-Aisle Purchasing System from Scratch
 
[WSO2Con Asia 2018] Patterns for Building Streaming Apps
[WSO2Con Asia 2018] Patterns for Building Streaming Apps[WSO2Con Asia 2018] Patterns for Building Streaming Apps
[WSO2Con Asia 2018] Patterns for Building Streaming Apps
 
Banking system i
Banking system iBanking system i
Banking system i
 
Tech talk ooad h2
Tech talk ooad h2Tech talk ooad h2
Tech talk ooad h2
 
Introduction to-ddd
Introduction to-dddIntroduction to-ddd
Introduction to-ddd
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Use cases - As approach to building shared vision
Use cases - As approach to building shared visionUse cases - As approach to building shared vision
Use cases - As approach to building shared vision
 
Jar chapter 4_part_ii
Jar chapter 4_part_iiJar chapter 4_part_ii
Jar chapter 4_part_ii
 
The atm system
The atm systemThe atm system
The atm system
 
The atm system
The atm systemThe atm system
The atm system
 
Jar chapter 4, part 1
Jar chapter 4, part 1Jar chapter 4, part 1
Jar chapter 4, part 1
 
ATM Banking
ATM BankingATM Banking
ATM Banking
 
vu-re-lecture-33 requirement engineering.ppt
vu-re-lecture-33 requirement engineering.pptvu-re-lecture-33 requirement engineering.ppt
vu-re-lecture-33 requirement engineering.ppt
 
A Review on Unified Payment Interface [UPI]
A Review on Unified Payment Interface [UPI]A Review on Unified Payment Interface [UPI]
A Review on Unified Payment Interface [UPI]
 
Open Payments Cloud at Findevr London 2017
Open Payments Cloud at Findevr London 2017Open Payments Cloud at Findevr London 2017
Open Payments Cloud at Findevr London 2017
 
Refining The System Definition
Refining The System DefinitionRefining The System Definition
Refining The System Definition
 
Corda Developer Bootcamp: Accounts
Corda Developer Bootcamp: AccountsCorda Developer Bootcamp: Accounts
Corda Developer Bootcamp: Accounts
 
Atm Simulator
Atm SimulatorAtm Simulator
Atm Simulator
 

Más de Jitendra s Rathore

Más de Jitendra s Rathore (7)

Aakash orientation Program for Technocrats
Aakash orientation Program for TechnocratsAakash orientation Program for Technocrats
Aakash orientation Program for Technocrats
 
Aakash tablet orientation prog for High school students
Aakash tablet orientation prog for High school studentsAakash tablet orientation prog for High school students
Aakash tablet orientation prog for High school students
 
Cloud computing it703 unit iii
Cloud computing it703 unit iiiCloud computing it703 unit iii
Cloud computing it703 unit iii
 
Cloud computing (IT-703) UNIT 1 & 2
Cloud computing (IT-703) UNIT 1 & 2Cloud computing (IT-703) UNIT 1 & 2
Cloud computing (IT-703) UNIT 1 & 2
 
Jeet ooad unit-2
Jeet ooad unit-2Jeet ooad unit-2
Jeet ooad unit-2
 
Ooad 3
Ooad 3Ooad 3
Ooad 3
 
lecturer plan
lecturer planlecturer plan
lecturer plan
 

Último

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 

Último (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 

Seq uml

  • 1. Modeling Behavior Interaction Diagrams Activity Diagram State Machine Diagram OOAD 1
  • 2. Learning Objectives Understand how to represent system logic with interaction diagrams. Understand how to represent system logic with activity diagram. Understand how to represent system logic with state machine diagram. Chapter 8 Appendix © 2008 by Prentice Hall 2
  • 3. UML Dynamic Modeling • In all systems, events happen dynamically, e.g.: – Objects are created and destroyed – Objects send messages to one another – External events trigger operations on certain objects • Objects have states that would be difficult to capture in a static model OOAD 3
  • 4. UML Dynamic Modeling (cont.) • Behavior diagrams (dynamic): – Interaction diagrams • Sequence diagrams • Collaboration diagrams – Statechart diagrams – Activity diagrams OOAD 4
  • 5. Sequence Diagrams: An example OOAD 5
  • 6. Collaboration diagram: An Example OOAD 6
  • 7. When to use Interaction Diagrams? • Interaction diagrams are used when you want to model the behavior of several objects in a use case.  They demonstrate how the objects collaborate for the behavior.  • Interaction diagrams do not give a in depth representation of the behavior.  If you want to see what a specific object is doing for several use cases use a state diagram.  To see a particular behavior over many use cases or threads use an activity diagrams. OOAD 7
  • 8. Messages are passed between objects, and may contain parameters (e.g., message name (parameter list))
  • 9. Sequence Diagrams • Describing the behavior of a system by viewing the interaction between the system and its environment • Shows the objects participating in the interaction by their life lines and the messages they exchange • Shows an interaction arranged in a time sequence OOAD 9
  • 10. 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. • Activation: the time period during which an object performs an operation. OOAD 10
  • 11. Objects/Classes Client ATMMachine SavingAccount Insert ATM card Request PIN Enter PIN code Verify PIN code PIN valid Request amount activation Enter amount Process transaction Transaction successful Dispense cash Print receipt lifeline
  • 12. Collaboration Diagrams • Also known as Communication diagrams • Represents a collaboration, which is a set of objects related in a particular context, and interaction, which is a set of messages exchanged among the objects within the collaboration to achieve a desired outcome • sequences of messages are shown by numbering OOAD 12
  • 13. 1: insert ATM card 3: enter PIN code 7: enter amount :ATMMachine :Client 2: request PIN 6: request amount 10: dispense cash 4: verify PIN code 11: print receipt 8: process transaction 5: valid PIN code 9: transaction successful :SavingAccount
  • 14. Sequence Vs Collaboration  Sequence Diagram: – Dynamic behavior of a set of objects arranged in time sequence, new objects added to the right – Good for real-time specifications and complex scenarios – easier to read  Collaboration Diagram : – Shows the relationship among objects. – Does not show time – Objects are arranged in a graph or network format • Both are used to examine the behavior of objects within a single use case OOAD 14
  • 15. How to draw sequence diagram? 9-15
  • 16. Drawing Sequence Diagrams  Determine the context of the sequence diagram  Identify the object that are participate in the sequence  Set of the lifeline for each object  Lay out of messages from the top to the bottom of the diagram based on the order in which they sent  Add the execution occurrence to each object’s lifeline  Validate the sequence diagram
  • 17. Identifying Classes/Objects • Noun phrase approach – read through the requirements or use cases looking for noun phrases • Some classes are implicit or taken from general knowledge • Carefully choose and define class names OOAD 17
  • 18. Use Case: Withdraw saving A customer wants to draw money from his bank account. He enters his card into an ATM (automated teller machine). The ATM machine prompts “ Enter PIN”. The customer enters his PIN. The ATM (internally) retrieves the bank account number from the card. The ATM encrypts the PIN and the account number and sends it over to the bank. The bank verifies the encrypted account and PIN number. If the PIN number is correct, the ATM displays, “Enter Amount”. Draws money from the bank account and pays out the amount. OOAD 18
  • 19. Use Case: Withdraw saving Use Case: Withdraw Saving Actors: Bank Client Flow of Events: 5. Bank client insert ATM card into ATM machine 6. ATM machine request PIN code 7. Bank client enter PIN code 8. Verify PIN code entered with saving account 9. ATM machine request amount if the PIN is valid 10. Bank client enter the required amount 11. Process the transaction in the client account 12. ATM machine dispense cash 13. ATM machine print receipt when the transaction completed Alternative Flow of Events • Invalid PIN code entered. Indicate error message. Return step 3. OOAD 19
  • 20. Identifying Classes – noun phrase approach (example) • ATM System – Bank Client – ATM Card – ATM Machine – Savings Account – Cash – Message OOAD 20
  • 21. Client ATMMachine SavingAccount Insert ATM card Request PIN Enter PIN code Verify PIN code PIN valid Request amount Enter amount Process transaction Transaction successful Dispense cash Print receipt
  • 23. ATM System ATM approval Deposit amount Client Withdraw amount Use case: ATM approval 2. Insert ATM card 3. Request PIN 4. Enter PIN 5. Verify PIN 6. Display message to client
  • 24. Client ATM Machine ClientDatabase Use case: ATM approval 2. Insert ATM card 3. Request PIN 4. Enter PIN 5. Verify PIN 6. Display message to client
  • 25.
  • 26.
  • 27.
  • 28. ATM System ATM approval Deposit amount Client Withdraw amount Use case: Withdraw amount 2. Request withdrawal amount 3. Enter withdrawal amount 4. Check account 5. Verify sufficient funds 6. Eject cash
  • 29. • Object naming – Syntax: [objectName]:[className] – Include object (instance) names when objects are referred to in messages or when several objects of the same type exist in the diagram – Name classes consistently with your class diagram Object A: Class A Object B: Class B :User messageA() messageB(“string”) messageC()
  • 30. Stereotypes of Analysis Classes  Classes or objects can be classified into one of the following three stereotypes: – Entity – to hold data – Boundary – used by actors to interact with the system For example: Customer place order, interact using a order form. – Control – coordinating behavior in the system For example: control the activities in the transaction (i.e., rules, calculations)
  • 31. Stereotypes of Analysis Classes Is an object relation that is extended to include responsibilities
  • 32. Stereotypes of Analysis Classes Is an object relation that is extended to include responsibilities
  • 33. Stereotypes of Analysis Classes A boundary class provides the interface between an actor and use case. The actor can be a human or an external system. Encapsulates connections between actors and use cases
  • 34. Stereotypes of Analysis Classes A boundary class provides the interface between an actor and use case. The actor can be a human or an external system. Encapsulates connections between actors and use cases
  • 35. Stereotypes of Analysis Classes A control class coordinates the tasks and captures the main logic in a use case. Mostly performs behaviors associated with inner workings of use cases
  • 36. Typically, actors interact with boundary classes, which in turn interact with control classes, which in turn interact with entity classes.
  • 37.
  • 38.
  • 39. Operations (behaviors) are depicted in the lower third of a class box. Operations fulfill the class’s responsibilities.
  • 40. Modeling Behavior Activity Diagram State Diagram OOAD 40
  • 41. Activity Diagram: An example OOAD 41
  • 42. When to use Activity Diagram? • The main reason to use activity diagrams is to model the workflow behind the system being designed.  • Activity Diagrams are also useful for: analyzing a use case by describing what actions need to take place and when they should occur;  describing a complicated sequential algorithm;  and modeling applications with parallel processes. OOAD 42
  • 43. Activity Diagram Focus on flow of activity of internal process in object similar to flowchart describe changes in activity in a procedure information from use case scenario or event flow can be used to describe activity diagram. Used to provide detail for complex algorithms OOAD 43
  • 44. Activity Diagram (cont.) • Purpose: – Modeling human task – Describe system’s function – Describe logic operation • Elements in activity diagram: Activity Transition Decision OOAD 44
  • 45. Example of Activity Diagram for Register Course start Fill form Select course [No] Submit to PA approve? [Yes] Register course end
  • 46. Example of Activity Diagram for ATM Authorization Enter card Read card Enter PIN Request PIN [No] Verify PIN valid? [Yes] Select other service
  • 47. Swimlane - partition an activity diagram so that parts in the swimlane relevant to that activities in the partition - helpful in investigating responsibilities for interactions and associations between objects and actors OOAD 47
  • 48.
  • 49. Activity diagram with synchronization bars – split into multiple paths and multiple paths combined into a single transition Top synchronization bar is a fork. Bottom synchronization bar is a join. OOAD 49
  • 50. OOAD 50
  • 51. When to use State Diagram? • Use state diagrams to demonstrate the behavior of an object through many use cases of the system.  • Only use state diagrams for classes where it is necessary to understand the behavior of the object through the entire system OOAD 51
  • 52. What is a State Diagram? • A diagram that captures the behavior of an object by specifying the sequence of states it goes through during its lifetime in response to events, together with the responses to those events • describe changes in state in a procedure • Also called statechart diagram or state machine diagram • State – a condition or situation during the life of an object at which time it satisfies some condition, performs some activity, or waits for some event. OOAD 52
  • 53. What is a State Diagram? (cont.) • A state diagram to describe the behavior (i.e., state changes) of a single class according to events and messages which class sends and receives • A state diagram can also clarify a use case – to specify the actions the use case can take in accordance with varying conditions of the system • E.g., a use case ‘enroll course’, the state can be full, opened, and closed. OOAD 53
  • 54. State Diagram Example Invoice created Invoice destroyed Paying Unpaid Paid
  • 55. Transition Notation State 1 Event(parameters) [condition] /action State 2 do/activity 1 ... Start state transition End state Example: Event(parameters) [condition] mouse_button_clicked(right_button)[inside the window] Example: /action /calculate amount
  • 56. State Notation Name compartment Action labels OOAD 56
  • 57.
  • 58. Recap • After studying this chapter we learned to: – Understand how to structure requirements with interaction diagram, activity diagram and state machine diagram. – Explain the element of sequence diagrams, activity diagram and state machine diagram. – Construct sequence diagrams, activity diagram and state machine diagram