states and activities

Post on 15-Apr-2017

95 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Arab Open University2nd Semester, 2006-2007

M301

Unit 4.5

States and Activities reem.attas@arabou.org.sa

Reem AlAttas © 2

Topic Road Map

Capturing more complex interactionsDesign issuesAn introduction to state machinesVariation of events and actionsPackages

Conditional Message Sends in Sequence Diagrams

Reem AlAttas © 4

If Statement

Guard

Reem AlAttas © 5

If .. Else Statement

Mutually Exclusive

Branch

Iterative Message Sends in Sequence Diagrams

Reem AlAttas © 7

For Loop

Reem AlAttas © 8

Topic Road Map

Capturing more complex interactions Design issuesAn introduction to state machinesVariation of events and actionsPackages

Reem AlAttas © 9

Defensive Programming

Pre-conditions should always be checked.

Disadvantage: conditions are repeatedly checked in different places.

Reem AlAttas © 10

Strategies for Implementing Use Cases

One Central Class.Actor Class.Use Cases as Classes.

Reem AlAttas © 11

Topic Road Map

Capturing more complex interactionsDesign issues An introduction to state machinesVariation of events and actionsPackages

Reem AlAttas © 12

The Essentials of State Machines

An event is an occurrence of a phenomenon at a certain moment in time and in a certain place.

Each state represents a particular period for which a given set of conditions applies.

Change takes place through transitions from one state to another. Transitions are said to be fired or triggered by events.

Reem AlAttas © 13

Two Simple States for a Room Object

Initial State

Event

Transition

Reem AlAttas © 14

… The Essentials of State Machines

An event when it occurs, has consequences. One consequence is a change of state. Other consequences are recorded in the action part of the label on the transition.

That is, instead of labeling a transition just with a simple name, we also record the actions (consequences) that result from the occurrence of the event.

Reem AlAttas © 15

Check In Sequence Diagram

Reem AlAttas © 16

Adding Detail to a State Machine for a Room Object

EventAction

;aGuest.setRoom (self)

Reem AlAttas © 17

A Simple State Machine for the Hotel Class

Self Transition

Reem AlAttas © 18

Self Transition

Originates in one state and returns to the same state.

If the same event is used on more than one transition, you must make sure that no more than one guard can evaluate to true. At most, you want just one transition to fire in such situations.

Reem AlAttas © 19

Entry and Exit Events

An entry event happens every time an object enters a state.

An exit event happens every time an object leaves a state.

Reem AlAttas © 20

… Entry and Exit Events

Reem AlAttas © 21

Internal Transition

A special transition that does not involve a change of state.

In contrast to a self-transition, an internal transition does not cause the execution of any entry or exit actions.

Reem AlAttas © 22

… Internal Transition

An internal transition may be used to handle an interrupt where you want some action to take place that does not affect the current state.

Internal transitions are written inside the state to which they refer.

Reem AlAttas © 23

Final State

A state chart diagram shows no more than one initial state but there can be zero, one or more final states.

Initial and final states signify the creation and destruction of an object.

Reem AlAttas © 24

Topic Road Map

Capturing more complex interactionsDesign issuesAn introduction to state machines Variation of events and actionsPackages

Reem AlAttas © 25

Other Kinds of Events

External Vs. Internal Events.Synchronous Vs. Asynchronous Actions.UML defined 4 types of events:

Call Events. Signal Events. Change Events. Time Events.

Reem AlAttas © 26

Time Event

Reem AlAttas © 27

Looking Inside States

Simple State: a state that contains no substructure.

Composite State: a state that has other states nested within it, in order to represent some internal behavior.

Reem AlAttas © 28

A Simple Telephone State Chart Diagram

Reem AlAttas © 29

A State Chart Diagram of the Composite State Active

Default Sub-state

Reem AlAttas © 30

No Default Sub-state

Reem AlAttas © 31

Topic Road Map

Capturing more complex interactionsDesign issuesAn introduction to state machinesVariation of events and actions Packages

Reem AlAttas © 32

Package

A general purpose mechanism for organizing model elements into groups.

Ex. A package allows you to gather together classes that share some common feature or behavior, such as order processing or stock control.

Reem AlAttas © 33

Why to Partition a S/W?

Manage size and complexity.Information hiding.Logical decomposition.

Reem AlAttas © 34

Typical MIS

Reem AlAttas © 35

Nested Packages

Reem AlAttas © 36

Packages Present Architecture

Three-tiered architecture advantages: Parallel development. Reusability. Distribution.

Reem AlAttas © 37

Subsystems

A subsystem has two sets of elements: Specification: Uses cases. Realization: Classes.

Reem AlAttas © 38

… Subsystems

Or <<subsyste

m>>

Operations

TMA4 – Q5

Thank You!

top related