Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

Object-Oriented Software Engineering

Using UML, Patterns, and Java

Dynamic Modeling
Chapter 5, Analysis:
Outline of the Lecture

• Dynamic modeling
• Interaction Diagrams
• Sequence diagrams
• Communication diagrams
• State diagrams
• Activity diagrams
• Requirements analysis model validation

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2
UML Diagrams

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3
Dynamic Modeling

• Describe components of the system that have


interesting dynamic behavior, using
• State diagrams: One state diagram per class with
interesting dynamic behavior
• Sequence diagrams: One sequence diagram per use
case for interaction between classes
• Activity diagrams: Model complex logic (business rules)
captured by a use case
• Purpose:
• Identify new classes in the object model and supply
operations for the classes.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4
How do we detect operations?

• We look for objects, who are interacting and


extract their “protocol”
• We look for objects, who have interesting
behavior on their own
• Good starting point: Flow of events in a use
case description
• From the flow of events, we proceed to the
sequence diagram to find the participating
objects.
• An event always has a sender and a receiver
• Find the sender and receiver for each event => These
are the objects participating in the use case.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5
Heuristics for Sequence Diagrams
• Layout:
• 1st column: Should be the actor of the use case
• 2nd column: Should be a boundary object
• 3rd column: Should be the control object that manages the rest
of the use case

•Creation of objects:
• Control objects are created by boundary objects initiating use
cases
• The control objects create the boundary objects

• Access of objects:
• Entity objects can be accessed by control and boundary objects
• Entity objects should not access boundary or control objects.
• This makes it easier to share entity objects across use cases and
makes entity objects resilient against technology-induced changes
in boundary objects.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6
An Example: Finding Objects from a
Sequence Diagram
• Let’s assume ARENA’s object model contains - at
this modeling stage – the following six objects
• League Owner, League, Tournament, Match and Player

League Owner League


1 *
Attributes Attributes
Operations Operations

Tournament
Attributes
Operations

Player * * Match
Attributes Attributes
Operations Operations
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7
An Example: Finding Objects from a
Sequence Diagram
• Let’s assume ARENA’s object model contains - at
this modeling stage – the following six objects
• League Owner, League, Tournament, Match and Player

• We now model the use case CreateTournament


with a sequence diagram

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8
ARENA Sequence Diagram: Create Tournament
:Tournament
Boundary :Arena :League
League
Owner

newTournament
(league)
:Announce
«new» Tournament
Control
checkMax
Tournament()
setName(name)

setMaxPlayers
(maxp)

commit() create
createTournament Tournament
(name, maxp) «new»
(name, maxp) :Tournament

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9
An Example: Finding Objects from a
Sequence Diagram

The Sequence Diagram identified 3 new Classes


• TournamentBoundary, AnnounceTournamentControl and
Arena

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10
ARENA Sequence Diagram: Create Tournament
:Tournament
Boundary :Arena :League
League
Owner

newTournament
(league)
:Announce
«new» Tournament
Control
checkMax
Tournament()
setName(name)

setMaxPlayers
(maxp)

commit() create
createTournament Tournament
(name, maxp) «new»
(name, maxp) :Tournament

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11
Impact on Arena’s Object Model
League Owner League
1 *
Attributes Attributes
Operations Operations

Arena TournamentBoundary

Attributes Attributes
Operations Operations
Tournament

Announce Attributes
Tournament Operations
Control

Attributes
Operations

Player Match
* *
Attributes Attributes
Operations Operations

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 12
Impact on ARENA’s Object Model (2)

• The sequence diagram also supplies us with many


new events
• newTournament(league)
• setName(name)
• setMaxPlayers(max)
• commit
• checkMaxTournament()
• createTournament

• Question:
• Who owns these events?
• Answer:
• For each object that receives an event there is a public
operation in its associated class
• The name of the operation is usually the name of the
event.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13
Example from the Sequence Diagram
:Tournament
Boundary :Arena :League
League
Owner

newTournament
(league)

:Announce
«new» Tournament
Control
checkMax
Tournament()
setName(name)

setMaxPlayers
(maxp)

commit() create
createTournament Tournament
(name, maxp) «new»
(name, maxp) :Tournament

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14
League Owner League
1 *
Attributes Attributes
Operations Operations

Tournament_
Boundary
Arena Attributes
Operations
Attributes
Tournament
Operations Announce_
Tournament_ Attributes
Control Operations
Attributes
createTournament
(name, maxp)

Player Match
* *
Attributes Attributes
Operations Operations
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 15
UML Interaction Diagrams

• Two types of interaction diagrams:


• Communication Diagram:
• Shows the temporal relationship among objects
• Position of objects is identical to the position of the
classes in the corresponding UML class diagram
• Good for identifying the protocol between objects
• Does not show time
• Sequence Diagram:
• Describes the dynamic behavior between several
objects over time
• Good for real-time specifications.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16
Example of a Communication Diagram
1) We start with the Class Diagram for 2Bwatch
2) Then we look at the sequence of events when
Joe sets the time on 2Bwatch

Watch LCDDisplay

Time

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17
Example of a Communication Diagram
Joe sets the time on 2Bwatch

:WatchUser
1:pressButtons1And2()
2:pressButton1()
3:pressButton2() 1.1:blinkHours()
4:pressButtons1And2() 2.1:blinkMinutes()
4.2:stopBlinking()
:Watch :LCDDisplay

3.1:incrementMinutes()
4.1:commitNewTime()

3.2:refresh()
:Time

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 18
Same Example with a Sequence Diagram

:WatchUser :Watch :LCDDisplay :Time


pressButton1and2()
blinkHours()
pressButton1()
blinkMinutes()
pressButton2()
incrementMinutes()
refresh()
pressButton1and2()
commitNewTime()
stopBlinking()

time
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 19
Review: UML Statechart Diagram Notation
Name of
Action
Event with parameters attr State

State1 Event
Event(attr) [condition]/action State2
do/Activity
entry /action Guard
condition
exit/action

• Note: Actions and Activities in State


• Events are italics
• Conditions are enclosed with brackets: []
• Actions are prefixed with a slash /
• Internal action and self-transition are different.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 20
Example of a StateChart Diagram

coins_in(amount) / set balance


Collect Money
Idle coins_in(amount) / add to balance
cancel / refund coins

[item empty] [select(item)] [change<0]

do/Test item and compute change


[change=0] [change>0]

do/Dispense item do/Make change

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 21
State Chart Diagram vs Sequence Diagram

• State chart diagrams help to identify:


• Changes to an individual object over time

• Sequence diagrams help to identify:


• The temporal relationship between objects over time
• Sequence of operations as a response to one ore more
events.

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 22
Checklist for a Requirements Review

• Is the model correct?


• A model is correct if it represents the client’s view of
the system
• Is the model complete?
• Every scenario is described
• Is the model consistent?
• The model does not have components that contradict
each other
• Is the model unambiguous?
• The model describes one system, not many
• Is the model realistic?
• The model can be implemented

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 23
Checklist for a Requirements Review (2)

• One problem with modeling:


• We describe a system model with many different views
(class diagram, use cases, sequence diagrams, state
charts)
• We need to check the equivalence of these views
• Syntactical check of the models
• Check for consistent naming of classes, attributes,
methods in different subsystems
• Identify double-defined classes
• Identify missing classes (mentioned in one model but
not defined anywhere)
• Check for classes with the same name but different
meanings

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 24
Examples for Inconsistency and
Completeness Problems
• Different spellings in different UML diagrams

• Omissions in diagrams

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 25
Different spellings in different UML
diagrams
UML Sequence Diagram UML Class Diagram

LeagueOwner League
1 *
createTournament Attributes Attributes
(name, maxp)
Operations Operations

Tournament_
Boundary
Attributes
Operations
Tournament
Announce_
Tournament_ Attributes
Control
Operations
Attributes

Different spellings
makeTournament
(name, maxp)
in different models
for the same operation Player Match
* *
Attributes Attributes
Operations Operations
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 26
Omissions in some UML Diagrams
Class Diagram

League Owner League


1 *
Attributes Attributes
Operations Operations

Tournament_ Missing
Boundary
Attributes Association
Operations (Incomplete
Tournament
Analysis?)
Missing class
Attributes
(The control object
Operations
AnnounceTournament
is mentioned in the
sequence diagram)

Player Match
* *
Attributes Attributes
Operations Operations
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 27
Requirements Analysis Document Template
1. Introduction
2. Current system
3. Proposed system
3.1 Overview
3.2 Functional requirements
3.3 Nonfunctional requirements
3.4 Constraints (“Pseudo requirements”)
3.5 System models
3.5.1 Scenarios
3.5.2 Use case model
3.5.3 Object model
3.5.3.1 Data dictionary
3.5.3.2 Class diagrams
3.5.4 Dynamic models
3.5.5 User interfae
4. Glossary

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 28
Section 3.5 System Models

3.5.1 Scenarios
- As-is scenarios, visionary scenarios
3.5.2 Use case model
- Actors and use cases
3.5.3 Object model
- Data dictionary
- Class diagrams (classes, associations, attributes and
operations)
3.5.4 Dynamic model
- State diagrams for classes with significant dynamic
behavior
- Sequence diagrams for collaborating objects (protocol)
3.5.5 User Interface
- Navigational Paths, Screen mockups
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 29
Requirements Analysis Questions
1. What are the functionalities of the system? Functional Modeling
Create scenarios and use case diagrams
- Talk to client, observe, get historical records
2. What is the structure of the system? Object Modeling
Create class diagrams
- Identify objects.
- What are the associations between them?
- What is their multiplicity?
- What are the attributes of the objects?
- What operations are defined on the objects?
3. What is its behavior?
Dynamic Modeling
Create sequence diagrams
- Identify senders and receivers
- Show sequence of events exchanged between objects.
- Identify event dependencies and event concurrency.
Create state diagrams
- Only for the dynamically interesting objects.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 30
Let’s Do Analysis: Summary

• Analyze the problem statement


• Identify functional requirements
• Identify nonfunctional requirements
• Identify constraints (pseudo requirements)
• Build the functional model:
• Develop use cases to illustrate functional requirements
• Build the object model:
• Develop class diagrams for the structure of the system
• Build the dynamic model:
• Develop sequence diagrams to illustrate the interaction
between objects
• Develop state diagrams for objects with interesting
behavior

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 31
Software Lifecycle Activities
covered

Object
Requirements System Implemen-
Analysis (Detailed) Testing
Elicitation Design tation
Design

Implemented
Expressed in By
Structured By Realized By
Terms Of Verified
By

class...
class...
class... ?
class.... ?
Use Case Application Solution
Domain Subsystems Source Test
Model Domain
Objects Code Case Model
Objects

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 32
Assignments

• Read Chapter 5
• Especially Section 5.6 ARENA Case Study

• Term Project – Step 2 (RAD-v1)


• Requirements elicitation
• Extended due date: 01.11.2022

• Term Project – Step 3 (RAD-v2)


• UI Mock-ups
• Due: 08.11.2022

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 33
Case Studies

• FRIEND – Analysis

• ARENA – Analysis

Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 34

You might also like