SEG 3101 Fall 2015 Requirements Modelling with UML

  • Slides: 52
Download presentation
SEG 3101 (Fall 2015) Requirements Modelling with UML 2 Miguel Garzón, University of Ottawa

SEG 3101 (Fall 2015) Requirements Modelling with UML 2 Miguel Garzón, University of Ottawa Based on Powerpoint slides by Gunter Mussbacher with material from: K. E. Wiegers, D. Leffingwell & D. Widrig, M. Jackson, I. K. Bray, B. Selic, Volere, Telelogic, D. Damian, S. Somé 2008, D. Amyot 2008 -2011, and G. v. Bochmann 2010

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram History of UML (http:

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram History of UML (http: //www. omg. org/uml/) Rumbaugh Jacobson Booch http: //www. omg. org/uml/ Official Version 2. 4. 1 (August 2011) UML 2. 5 Beta “simplified”: 831 pages! Source: http: //en. wikipedia. org/wiki/Unified_Modeling_Language SEG 3101. Requirements Modelling with UML 2

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Dilbert on Standards SEG

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Dilbert on Standards SEG 3101. Requirements Modelling with UML 3

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Thirteen Diagram Types in

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Thirteen Diagram Types in UML 2. x • According to UML Reference Manual • Structural • Class, object, composite structure, component, and use case diagrams • Dynamic (that is, describing dynamic behavior) • State machine, activity, sequence, communication, timing, and interaction overview diagrams • Physical • Deployment diagrams • Model Management • Package diagram SEG 3101. Requirements Modelling with UML 4

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Most Relevant for Requirements

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Most Relevant for Requirements Engineering • Use case diagram • Use cases structuring • Class diagram • Domain modeling • Activity diagram • Workflow and process modeling • Concepts much related to concepts of Use Case Maps • Sequence diagram • Modeling of message exchange scenarios • State machine diagram • Detailed behavioral specification (of objects, protocols, ports…) • System behaviour (black box) SEG 3101. Requirements Modelling with UML 5

Class Diagram

Class Diagram

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Entity-relationship modeling (ERM) Entity-Relationship

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Entity-relationship modeling (ERM) Entity-Relationship modeling (originally proposed by Peter Chen in 1976) • Concepts: • Entity: represents a type of entity instances, defines the properties that hold for all such instances. • Relationship: represents relationship instances that hold between certain pairs of entity instances. • The related entity types are also called roles. • Multiplicity information indicate how many instances of the “other” side may be related to a given instance of “this” side. • Attribute: An entity or a relationship may have one or several attributes. Each attribute is identified by a name and its type, where such a type is usually some simple data type such as integer or character string. Note: An entity type is normally not used as the type of an attribute, because such a situation is rather represented by a relationship between the given entity and the attribute type. SEG 3101. Requirements Modelling with UML 7

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram ERM – Notations •

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram ERM – Notations • There a variety of notations that have been used for ERM • Chen’s notation SEG 3101. Requirements Modelling with UML 8

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram UML Class Diagrams SEG

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram UML Class Diagrams SEG 3101. Requirements Modelling with UML 9

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Methodology for Object-Oriented Analysis

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Methodology for Object-Oriented Analysis (OOA) • Five main steps • Identify core classes within problem domain • Model relationships between classes • Class diagram • Define the attributes associated with each class • Determine relevant operations for each class • Define the messages that may be passed between objects • Interaction diagram, state machine diagram SEG 3101. Requirements Modelling with UML 10

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Exercise… • Design a

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Exercise… • Design a simple domain model for a genealogy software application • What are the relevant classes, attributes and associations? • Do you see some constraints that are difficult to express with UML class diagrams? SEG 3101. Requirements Modelling with UML 11

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Problems with Class Diagrams

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Problems with Class Diagrams (1) • Caution: OOA not always analysis • Most OOA approaches actually address high-level design… • Class diagrams can however be used for analysis, especially for the description of domain concepts • Further composition and decomposition problems • Related requirements cannot all be assigned to a single component or a single class • One scenario may affect several classes at once • OO modularization is not perfect either. . . Scattering and tangling effects - Motivation for aspect-oriented analysis and design SEG 3101. Requirements Modelling with UML 12

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Problems with Class Diagrams

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Problems with Class Diagrams (2) Scattering: design elements to support R 1 in many components Requirement 1 (R 1) Requirement 2 (R 2) Component. A Requirement 3 (R 3) R 1 elements … Requirement. N (RN) Component. B Component. C Component. D R 1 elements Component. F Component. E R 1 elements R 2 elements R 3 elements RN elements Tangling: single component has elements for many requirements SEG 3101. Requirements Modelling with UML 13

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram A Partial Solution –

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram A Partial Solution – Aspects intertype declaration Aspect Class. A R 1 elements F. R 1 advice Class. G Triggered behavior (code) R 1 elements Class. C Predicate R 1 elements Class. B R 1 elements pointcut (identifies joinpoints where advice is executed) Class. F R 1 elements R 2 elements R 3 elements RN elements Terminology based on Aspect. J: www. eclipse. org/aspectj SEG 3101. Requirements Modelling with UML 14

Activity Diagrams (for your information only)

Activity Diagrams (for your information only)

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Basic Notational Elements of

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Basic Notational Elements of Activity Diagrams • Describe the dynamic behavior of a system as a flow of activities (workflow) • Flow • Sequence • Alternative • Parallel • Note: in this diagram, the data flow objects are not shown. They may be shown as boxes on the control flow lines. SEG 3101. Requirements Modelling with UML 16

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Partitions – Examples SEG

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Partitions – Examples SEG 3101. Requirements Modelling with UML 17

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram UCM or UML Activity

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram UCM or UML Activity Diagrams? • UCM and activity diagrams have many concepts in common • Responsibility action • Start/end points • Alternatives (fork / join) • Concurrency (fork / join) • Stub / plug-in action / sub-activity diagram • Association between elements and components / partition • Both may represent operational scenarios and business processes SEG 3101. Requirements Modelling with UML 18

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Unique to UCM •

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Unique to UCM • Dynamic stubs with several plug-ins • Activity diagrams have a single sub-activity diagram per action • Synchronizing/Blocking stubs • Plug-ins can continue in parallel with their parent model • Sub-activity diagrams must complete before returning to the parent activity diagram • 2 D graphical layout of components • Definitions of scenarios (integrated testing capabilities!) • Integration with GRL in URN SEG 3101. Requirements Modelling with UML 19

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Unique to Activity Diagrams

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Unique to Activity Diagrams • Data flow modeling • Conditions on parallelism (branches of an AND-fork) • Can be captured in UCM with Synchronizing Stubs • Constraints on action pins • Integration with UML (including class diagrams and OCL) SEG 3101. Requirements Modelling with UML 20

Sequence Diagrams

Sequence Diagrams

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Basic Notational Elements of

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Basic Notational Elements of Sequence Diagrams • Describe the dynamic behavior as interactions between so- called “participants” (e. g. agents, actors, the system, system components). For each participant, there is a “lifeline” participant SEG 3101. Requirements Modelling with UML 22

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Lifelines and (A)synchronous Interactions

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Lifelines and (A)synchronous Interactions • Participants, shown using lifelines, participate in the interaction sequence by sending / receiving messages • Messages can be synchronous or asynchronous SEG 3101. Requirements Modelling with UML 23

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments • Allow

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments • Allow multiple sequences to be represented in compact form (may involve all participants or just a subset) • Combined fragment operators • alt, for alternatives with conditions • opt, for optional behavior • loop(lower bound, upper bound), for loops • par, for concurrent behavior • critical, for critical sections • break, to show a scenario will not be covered • assert, required condition • ignore/consider(list of messages), for filtering messages • neg, for invalid or mis-use scenarios that must not occur • strict or seq, for strict/weak sequencing (WHAT IS THIS ? ) • ref, for referencing other sequence diagrams SEG 3101. Requirements Modelling with UML 24

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments – Alternative

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments – Alternative • Alternative (operator alt) • Multiple operands (separated by dashed lines) • Each operand has guard condition (no condition implies true) • One will be chosen exclusively – nondeterministically if more than one evaluates to true • Special guard: else • True if no other guard condition is true SEG 3101. Requirements Modelling with UML 25

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments – Optional

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments – Optional • Optional (operator opt) • To specify a guarded behavior fragment with no alternative • Special case of alt • Equivalent to an alt with two operands • The first is the same as the operand for the opt • The second is an empty operand with an else guard SEG 3101. Requirements Modelling with UML 26

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments – Loop

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments – Loop • Loop (operator loop) • Loop fragment may execute multiple times • At least executed the minimum count • Up to a maximum count as long as the guard condition is true (no condition implies true) minimum, maximum count Source for Password Example: UML Reference Manual SEG 3101. Requirements Modelling with UML 27

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments – Concurrency

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Combined Fragments – Concurrency • Concurrency (operator par) • Two or more operands that execute in parallel SEG 3101. Requirements Modelling with UML 28

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Concurrency Quiz – Part

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Concurrency Quiz – Part One! • Is the interaction on the right a valid sequential trace that can be generated from the interaction with the par combined fragment on the left? • No! The sequences of the two operands may be interleaved but the ordering defined for each operand must be maintained. SEG 3101. Requirements Modelling with UML 29

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Nested Combined Fragments SEG

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Nested Combined Fragments SEG 3101. Requirements Modelling with UML 30

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Temporal Aspects (For Your

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Temporal Aspects (For Your Information Only!) SEG 3101. Requirements Modelling with UML 31

State Machine Diagram

State Machine Diagram

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Basic Notational Elements of

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Basic Notational Elements of State Machine Diagrams • Describe the dynamic behavior of an individual object (with states and transitions) SEG 3101. Requirements Modelling with UML 33

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Types of State Machines

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Types of State Machines on on Lamp On print(”on”) Lamp On on on/print(”on”) off Lamp Off off Mealy Automaton Lamp Off off Moore Automaton • UML allows both types to be mixed SEG 3101. Requirements Modelling with UML 34

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Variables (“Extended” States) on

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Variables (“Extended” States) on ctr : Integer Lamp On on/ctr : = ctr + 1 off Lamp Off SEG 3101. Requirements Modelling with UML 35

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Modeling Behavior • In

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Modeling Behavior • In general, state machines are suitable for describing reactive systems based or events • Not appropriate to describe continuous systems (e. g. , spacecraft trajectory control, stock market predictions) threshold time SEG 3101. Requirements Modelling with UML 36

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram UML State Machine Diagrams

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram UML State Machine Diagrams – Summary Composite State Initial Pseudostate State top Trigger Ready Transition stop /ctr : = 0 Done Final State stop Action SEG 3101. Requirements Modelling with UML 37

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Entry and Exit Actions

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Entry and Exit Actions Lamp. On entry/lamp. on(); e 2 exit/lamp. off(); e 1 SEG 3101. Requirements Modelling with UML 38

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Action Ordering Lamp. On

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Action Ordering Lamp. On entry/lamp. on(); off/printf(“to off”); exit/printf(“exiting”); Resulting action sequence: printf(“exiting”); printf(“to off”); lamp. off(); Lamp. Off entry/lamp. off(); exit/printf(“exiting”); off/printf(“needless”); printf(“exiting”); printf(“needless”); lamp. off(); • Output actions: transition prefix • Input actions: transition postfix SEG 3101. Requirements Modelling with UML 39

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram State Activity (Do) •

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram State Activity (Do) • Creates a concurrent process that will execute until • The action terminates, or • We leave the state via an exit transition “do” activity Error entry/printf(“error!”) do/alarm. ring() SEG 3101. Requirements Modelling with UML 40

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Guards (Conditions) • Conditional

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Guards (Conditions) • Conditional execution of transitions bid [value < 100] /reject Selling bid [value >= 200] /sell Happy bid [(value >= 100) & (value < 200)] /sell Unhappy • Guards must not have side effects SEG 3101. Requirements Modelling with UML 41

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Hierarchical State Diagrams •

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Hierarchical State Diagrams • Composed states, to manage complexity Lamp. Off entry/lamp. off() flash/ Lamp. Flashing Flash. On entry/lamp. on() off/ on/ Lamp. On 1 sec/ on/ 1 sec/ Flash. Off entry/lamp. off() entry/lamp. on() SEG 3101. Requirements Modelling with UML 42

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Group Transitions Default transition

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Group Transitions Default transition to Initial pseudostate Lamp. Off entry/lamp. off() flash/ Lamp. Flashing Flash. On entry/lamp. on() off/ 1 sec/ on/ Lamp. On on/ 1 sec/ Flash. Off entry/lamp. off() entry/lamp. on() Group transition SEG 3101. Requirements Modelling with UML 43

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Completion Transition • Triggered

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Completion Transition • Triggered by a completion event • Automatically generated when an embedded state machine terminates Committing Completion transition (without trigger) Phase 1 Commit. Done Phase 2 SEG 3101. Requirements Modelling with UML 44

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Triggering Rules • Many

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Triggering Rules • Many transitions can share the same triggering event • When leaving, the most deeply embedded one takes precedence • The event disappears whether it triggers a transition or not Lamp. Flashing Flash. On on/ off/ Flash. Off SEG 3101. Requirements Modelling with UML 45

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Action Ordering – Composite

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Action Ordering – Composite States S 1 exit/ex. S 1 S 2 entry/en. S 2 /init. S 2 S 11 exit/ex. S 11 E/act. E S 21 entry/en. S 21 Action sequence on transition E: ex. S 11 ex. S 1 act. E en. S 2 init. S 2 en. S 21 SEG 3101. Requirements Modelling with UML 46

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Exercise I – Describe

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Exercise I – Describe this Behavior • What should be added to this state machine to more fully describe the dialing behavior? SEG 3101. Requirements Modelling with UML 47

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Orthogonal Regions • Combine

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Orthogonal Regions • Combine many concurrent perspectives – interactions across regions typically done via shared variables age financial. Status Child Poor Adult Retiree age financial. Status Rich Child Poor Adult Retiree Rich SEG 3101. Requirements Modelling with UML 48

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Semantics of Orthogonal Regions

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Semantics of Orthogonal Regions • All mutually orthogonal regions detect the same events and respond simultaneously (possibly interleaved) legal. Status Law. Abiding rob. Bank/ Outlaw financial. Status Poor rob. Bank/ Rich SEG 3101. Requirements Modelling with UML 49

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Exercise II – Describe

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Exercise II – Describe this Behaviour Course. Attempt Studying Lab 1 lab done Lab 2 lab done project done Term Project pass Final Test fail Failed Passed SEG 3101. Requirements Modelling with UML 50

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Exercise III • In

Introduction Class Diagram Activity Diagram Sequence Diagram State Machine Diagram Exercise III • In requirements engineering, state machines are quite popular for describing the lifecycle of documents and other artefacts. • Using a UML state machine diagram, describe the lifecycle of: • An prerequisite exemption request for a course at the University of Ottawa. • A software bug in a bug management system such as Bugzilla. SEG 3101. Requirements Modelling with UML 51

Conclusion… SEG 3101. Requirements Modelling with UML 52

Conclusion… SEG 3101. Requirements Modelling with UML 52