Docsity

Behavior Modeling - Software Architecture and Design | CS 6310, Study notes of Computer Science

Toggle sidebar
bg1
Behavior Modeling
• Class models express properties that are
true of a system at all times
• Although they are general, they fail to
convey interesting behavioral aspects of
systems
– That is, how objects respond to external stimuli
• A variety of alternative modeling techniques
are available in UML for behavior modeling
– Use case diagrams, sequence diagrams,
statechart diagrams, activity diagrams, timing
diagrams, interaction overview diagrams,
communications/collaboration diagrams
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34

Partial preview of the text

Download Behavior Modeling - Software Architecture and Design | CS 6310 and more Study notes Computer Science in PDF only on Docsity!

Behavior Modeling

  • Class models express properties that are

true of a system at all times

  • Although they are general, they fail to

convey interesting behavioral aspects of

systems

  • That is, how objects respond to external stimuli
  • A variety of alternative modeling techniques

are available in UML for behavior modeling

  • Use case diagrams, sequence diagrams, statechart diagrams, activity diagrams, timing diagrams, interaction overview diagrams, communications/collaboration diagrams

Modeling Alternatives

• Combinatorial

Control

  • Decision tables
  • Decision trees

• Sequential Control

  • State transition

tables

  • Finite state

machine

• Concurrent Control

  • State charts
  • Petri Nets
  • Activity diagrams
  • Sequence

diagrams

  • Collaboration

diagrams

  • Temporal logic
  • Process algebra

Decision Tables

  • One common way to model control is with decision tables. They are used when a number of possible input conditions hold and a number of responses are possible
  • The conditions are called inputs and the responses are called outputs
  • The input side of the table enumerates all possible combinations of conditions. For example, if each of three switches can have one of two possible values, "on" or "off", then the table will contain three columns and eight rows
  • Likewise, if the three switches control two output devices (one switch is a master override) then there will be two output columns (along with the eight rows from the input). 3

Example Decision Table - 1

INPUT Output Master Control Light Switch Power Switch Lights Motor ON ON ON ON ON ON ON OFF ON OFF ON OFF ON OFF ON ON OFF OFF OFF OFF OFF ON ON OFF OFF OFF ON OFF OFF OFF OFF OFF ON OFF OFF OFF OFF OFF OFF OFF

Decision Trees

• A decision tree contains the same

information as a decision table, but in

graphical form

• There are two kinds of nodes

  • Diamonds denote decisions
  • Rectangles denote actions to be taken

• Labeled arcs indicate the implications

when a decision is answered in a

particular way (affirmative or negative)

• Note that some nodes may be duplicated

Example

Decision

Tree

Master Controller On? Light Off / Motor Off Light Switch On? Power Switch On? Light On / Motor On Light Off / Motor On Light On / Motor Off Power Switch On? Light Off / Motor Off Yes No Yes No Yes No Yes No

States

  • A state is an abstract summary of the set of

values for system attributes at a given

instance

  • A condition or situation during the life of an

object during which it satisfies some

condition, performs some activity, or waits

for some event - UML Reference Manual

  • The state of a system varies as it performs

operations

  • The set of all possible states of a system is

called its state space

  • What is the size of a state space?

Events

  • At any given moment, an object is in exactly one state
  • An object's state can change in response to a stimulus; for example, the execution of an operation
  • The term used to describe an atomic stimulus is an event
  • The event can lead to a change of state, called a transition
  • Events can be synchronous or asynchronous
  • Events can occur as the results of actions (the user hits a button), data conditions (the temperature gets above 90°) or the passage of time

State Transition Table (STT)

  • Rows correspond to states, and there are four

columns

  • Name
  • Input event; a given state may need to have several rows, one for each allowable input event
  • Output actions
  • Next state
  • That is, a state transition table captures the

idea that a system in a given state receives

an input event, takes action upon it possibly

producing an output and then moves into

another state

STT for Garage Door Opener

Current State Input Action Next State Door Closed Motor Off Button Pressed Start Motor Motor Running Up Motor Running Up Door Open Detected Stop Motor Door Open Motor Off Motor Running Up Button Pressed Stop Motor Door Partially Open Motor Off Door Partially Open Motor Off Button Pressed Start Motor Motor Running Down Door Open Motor Off Button Pressed Start Motor Motor Running Down Motor Running Down Door Closed Detected Stop Motor Door Closed Motor Off Motor Running Down Button Pressed Stop Motor Door Partially Closed Motor Off Door Partially Closed Motor Off Button Pressed Start Motor Motor Running Up

State Transition Diagrams

  • A system's states and events are most commonly modeled as a finite state machine–a directed graph, where nodes correspond to states, and arcs correspond to transitions
  • Diagrams denoting finite state machines (FSMs) are called State Transition Diagrams
  • State are denoted by labeled bubbles (ovals or rectangles)
  • A state transition diagram is always in exactly one state ( i.e. it is deterministic). When an input event occurs, the machine moves to another state and (optionally) performs an action
  • States are connected by labeled directed arcs denoting the transitions among the states
  • The labels on the arcs consist of two parts. The first is the event provoking the transition. The second is any action performed during the transition
  • State transition diagrams contain exactly the same information as state transition tables - The layout of nodes and arcs has no semantic import

Example: Garage Door Opener

Door Closed Motor off button pressed/ start motor Motor Running Up door open detected/ stop motor Door Open Motor off / start motor door closed detected/ stop motor Door Partially Closed Motor off Motor Running Down button pressed/ start motor button pressed/ Door Partially Open stop motor Motor off button pressed/ stop motor button pressed/ start motor

Example: Telephone

ON HOOK OFF HOOK DIALING RINGING BUSY CONNECTED Handset lifted Handset replaced Number dialed Number dialed Handset replaced Handset replaced Handset replaced Handset replaced Line in use Last number dialed Callee answers Callee hangs up

Notes

• One of the states, ON HOOK , is denoted

with concentric circles. In this case, it

indicates that the state is the initial state of

the system

• The DIALING state has a transition back

to itself

  • The fact that dialing itself has many states

has been abstracted out of this diagram

• There is a great deal of duplication in the

diagram