Behavioral Modeling with UML 2.0 PowerPoint Presentation derived from Dennis, Wixom & Tegarden Systems Analysis and Design John Wiley & Sons, Inc.. and.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Behavioral Modeling with UML 2.0Behavioral Modeling with UML 2.0
PowerPoint Presentation derived from Dennis, Wixom & Tegarden Systems Analysis and Design
When to Use Which Diagram?• UML is not a method or a
process, it is a visual language
• The different diagrams are like “tools” in a “tool-box”, each with a different intended use
Use Case Diagram
Use Case Diagram
StatechartDiagram
StatechartDiagram
Sequence Diagram
Sequence Diagram
Architecture Diagram
Architecture Diagram
ClassDiagram
ClassDiagram
CONTEXT: PROCESS MODELS
How Does UML Fit Into a Process?
• UML is the communication language used during the Analysis and Design Phases – aids communication between stakeholders and developers
• Using UML a complete, accurate and fully consistent description of the system can be created
• Using UML allows mistakes and errors to be easily identified. The process of looping through the system, removing errors is absolutely essential and unavoidable, and is described as iteration.
• Iteration occurs within all phases
The Waterfall Process• Divides the project into well-defined phases with intermediate
milestones• Each phase depends on the completion of the previous• The final product is not delivered until all phases are finished • Works best on small projects• Waterfall method has many advantages:
– it is the most direct way to the objective with the shortest development time and cost possible
• However, the drawbacks of this method include:– little flexibility for scope changes– system limitations not being discovered until later in
the development cycle– clients not being able to see the product until it is
completely finished
Analysis
Design
Implementation
Test
The Spiral Process• The spiral process is an iterative process
– Recognizes the need to visit requirements analysis/design/implementation/test sequence more than once
– Several reasons for this:• Identification and resolution of risks• Review of earlier “prototype” versions by the user to elicit
feedback. • Spiral model focus: to address
risks incrementally in order of priority
• Rounds follow the waterfall process
Analysis Design
Testing Implementation
The Iterative and Incremental Process
• A logical extension to the spiral model, but more formal and rigorous
• Structured in four phases: Inception, Elaboration, Construction and Transition
TransitionConstructionElaborationInception
Requirements Phase
ImplementationDesignAnalysisRequirements Test
Requirements Phase
Analysis Phase
ImplementationDesignRequirements TestAnalysis
Analysis Phase
Analysis Phase
• Understand the problem domain • Create a model describing the problem domain
– Free from any technical or implementation details– Detailed enough to allow simulation on paper or by using a
modeling tool• Activities:
– Acquire domain knowledge– Perform use case analysis– Define the necessary classes and relationships– Define the behavior and collaboration between classes– Test the resulting model
Analysis Phase
• Use Case Model with detailed use case descriptions– Natural language– Sequence diagram– Activity diagram– State Machine diagram
• Domain Model– Class diagram showing domain concepts and
their relationships
• System Interface Class Diagram– Interface Classes– Signals that compose the interfaces– Data types used by the signals
DeliverablesAnalysis Phase
When is the Analysis Phase Finished?
• When the Use Cases describe the functional aspects of the System to build
• When the Conceptual Model expresses the major components of the problem domain
• When the system interface is well defined• When developers feel comfortable estimating
the time it will take to develop each use case
Analysis Phase
BEHAVIORAL MODELS
Behavioral Models
• Systems have static &dynamic characteristics– Structural models describe the static aspects of
the system– Behavioral models describe the dynamics and
interactions of the system and its components
• Behavioral models describe how the classes described in the structural models interact in support of the use cases.
INTERACTION DIAGRAMS
Interaction Diagram Components
• Objectsan instantiation of a class
• Operationsthe behaviors of an instance of a class
• Messagesinformation sent to objects to tell them to execute
Communication Diagram Contents: Links and Messages
: Student
: RegisterForCoursesForm
: RegistrationController : CourseCatalogSystem
5: display course offerings( )
6: display blank schedule( )
: Course Catalog1: create schedule( )
2: get course offerings( )
3: get course offerings(forSemester)
4: get course offerings( )
Links
Messages
Sequence and Communication Diagram Similarities
• Semantically equivalent– Can convert one diagram to the other without
losing any information
• Model the dynamic aspects of a system• Model a use-case scenario
Sequence and Communication Diagram Differences
Sequence diagrams
Communication diagrams
Show the explicit sequence of messages
Show execution occurrence
Better for visualizing overall flow
Better for real-time specifications and for complex scenarios
Show relationships in addition to interactions
Better for visualizing patterns of communication
Better for visualizing all of the effects on a given object
Easier to use for brainstorming sessions
ACTIVITY DIAGRAMS
Activity Diagrams
• Activity diagrams describe the workflow behavior of a system
• Activity diagrams can show activities that are conditional or parallel.
• Activity Diagrams are useful for: – analyzing a use case by describing what actions need
to take place and when they should occur – describing a complicated sequential algorithm– modeling applications with parallel processes– modeling bussiness workflow
Analysis Phase
Activity Diagram - elementsAnalysis Phase
Fork Join
Decision Node
Object Node
Action Node
Initial Node
Activity Final
Guard
Activity Diagram Symbols - 1Initial nodeStarting point for invocing other activities. An activity may have several starting points.
Action/ActivityAn action is an executable unit. Can also refer to a new activity diagram.
Activity2
if (a) { x = 7; }
Analysis Phase
Action States and Activity States
• Each state in an activity diagrams is either:– an action state
• describes an atomic action• the outgoing transitions are implicitly triggered by the
completion of the action in the state– or an activity state
• describes an enduring activity which can be interrupted• invokes an activity graph• the activity state is not exited until the final state of the
nested graph is reached.
Analysis Phase
Activity Diagram Symbols - 2
Class3
Object nodeRepresents an instance of a clasifier, usually a classUsed to show input to or output from an action.An object flow shows objects being generated or used by actions or activities in activity diagrams
Analysis Phase
UpdateOrder
UpdateOrder
CustomerOrderCustomerOrder
PrepareInvoice
PrepareInvoice
Activity Diagram Symbols - 3Decision nodeA decision node is a control node that chooses between outgoing flows.Each branch has its own guard condition“Else” may be defined for at most one outgoing transition
x
Fork/Join symbolDivides a flow into multiple concurrent flows. Flows can be split and synchronized again.
Analysis Phase
Activity Diagram Symbols - 4
Connector symbolLabel and Join
Signal12
Accept event symbolRepresents an input action.
Send signal symbolRepresents an output action.
Accept time event symbolRepresents a timeout situation. To set a timer, use textual syntax in an action node
Analysis Phase
Activity Diagram Symbols - 5Activity final symbolAborts all flows in the containing activity.
Flow final symbolDestroys all tokens that arrive at it, but has no effect on other flows.
Integer i; Text symbol
Comment symbol: • unconnected or unselected it looks almost like a text symbol.
Analysis Phase
//MyComment
Activity Diagram Symbols - 6SL1
Activity Partition (Swim lanes)Swim lanes visually group the action states. They have no semantics but are often used to show a relation between activities, for example activities performed by a person, business unit etc.Swimlanes can also contain other swimlanes. You can also indicate that a swimlane represents a certain part or that it represents an external entity.SL3
SL3
SL2
SL2
SL1c3:Class3
<<external>>
SL1c3:Class3
<<external>>
Analysis Phase
Activity Diagram – Swimlane Example
• Transitions can take place from one swim lane to another
Analysis Phase
AccountList
ControlUnit
Customer
'Prompt For Card'
[Display("Insert Card")]
[Display("Insert Card")]
'Customer Inserts Card'
Card
'Prompt for Pin'
[Display("Enter Pin")]
[Display("Enter Pin")]
'Customer Provides Pin'
ValidateCardandPin
Pin
CardInfo
ValidateCardInfo
Activity Diagram – Example
Card Inserted
System promptsfor PIN
Customerenters PIN
Log invalid PIN
Validate PIN
Selecttransaction type
Prompt PIN invalid
[PIN invalid][PIN valid]
Reject card
[NbrOfAttempts < 3]
System promptsfor amount
System promptsfor currency
[Withdrawal] [Foreign currencytransaction]
Customer entersamount
Customerenters currency
Analysis Phase
Guard: Follow this path, only if the text in the brackets [ ] evaluates to true.
Activity Diagram Guidelines• Keep the diagram simple
– The focus is easy communication. Don’t be too formal• Swimlanes should only represent the Actors and the
System• All required Object Nodes should be part of the Conceptual
Model– Revise the Model if necessary
• Try to capture all the scenarios of the Use Case in one diagram– But be careful not to overload the diagram. If necessary use
more than one per Use Case• Emphasize the collaborative and parallel aspects of the
behavior
Analysis Phase
Drawing Activity Diagram• Remember, this is an iterative process• Select a Use Case to model• Look at all scenarios:
– Basic: positive and straightforward behavior– Alternative– Exception
• Find the Use Case participants• Find the main activities
– Internal and Intermediate activities will be defined in later phases• Find the Decision Criteria that defines the transition between
activities• Find the Input and the Output for the activities• Determine which activities are parallel/concurrent and which ones
are sequential
Analysis Phase
Exercise 8
Assignment Build Activity Diagram• Identify the participating candidates and draw the
associated swim lane
• Identify and define activities
• Identify and define transitions between those activities
• Add the necessary decision nodes that are necessary to understand the use case
• If pertinent, add the Object Nodes and Flows
Analysis Phase
BEHAVIORAL STATE MACHINES
State Machine Diagram
• A state machine diagram specifies the dynamic behavior of an element in a reactive, event-driven way
• Specifies a finite number of states of an element and how transitions between states are performed in response to events
• Typically not used for all objects– Just for complex ones
Analysis Phase
State Machine Diagram Usage
• To elaborate use case specifications• To specify high-level system behavior during
analysis• Capture significant events that can act on an
object
Analysis Phase
System Level State Machine Diagram
• Defining a System Level State Machine that includes all Use Cases would be unrealistic– Too many system states– Too many possible transitions
• Instead, a System Level State Machine should be created to show only some aspects of the functionality
• Each of these State Machines could be used to do partial simulation of the System– On paper– Using a UML tool
Analysis Phase
Components of State Machines
• Statesvalues of an object’s attributes at a point in time
• Eventschange the values of the object’s attributes
• Transitionsmovement of an object from one state to another