Download presentation
Presentation is loading. Please wait.
Published byHarjanti Setiawan Modified over 5 years ago
1
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
( ) OBJECT ORIENTED ANALYSIS AND DESIGN III B. Tech II Sem UNIT-4
2
Advanced Behavioral Modeling
3
Events – External vs. Internal Events
Events can be categorized into external or internal events. External events are those that pass between the Actors and the system. Event Event System Internal events pass between objects residing within the application system. NetworkElement elementPort: Port NetworkController consolePort[2..*] : Port 1
4
Events – 4 Kinds: Signals; Calls; Passing of Time; Change in State
Signal - kind of event that represents the specification of an asynchronous stimulus communicated between instances. Modeled as a class Dispatched (thrown) by one object and continues flow of execution Received (caught) by another object at some future point in time. Can be sent as: Action of a state transition Message in an object interaction Dependencies <<send>> show signals sent by a class Exceptions are the most common kind of internal signal. signal MovementAgent TroubleManager position <<signal>> velocity <<send>> Collision Signals moveTo force : float collision( force : float ) send dependency powerLoss powerDown Signal parameters Modeling Signal Receiver: as an active class; Consider 4th compartment for signals.
5
Events – 4 Kinds: Signals; Calls; Passing of Time; Change in State
Time & Change Event Call Events Represents the dispatch of an operation Synchronous Time event - represents the passage of time: after( periodOfTime ) Change event - represents a change in state or the satisfaction of some condition: when( booleanExpr ) event change event when( 11:49pm ) / selfTest() startAutopilot( normal ) Manual Automatic time event Idle parameter after( 2 sec ) / dropConnection() Active
6
Modeling Family of Signals and Exceptions
Signal events are typically hierarchical. Look for common generalizations. Look for polymorphic opportunities. Consider the exceptional conditions of each class. Arrange exceptions in generalization hierarchy. Specify the exceptions that each operation may raise. Use send dependencies Show in operation specification <<signal>> RobotSignal <<exception>> Exception setHandler() <<signal>> <<signal>> Collision HardwareFault firstHandler() lastHandler() sensor : int <<exception>> <<signal>> <<signal>> <<signal>> <<signal>> Duplicate BatteryFault MovementFault VisionFault RangingFault <<send>> <<exception>> Overflow item <<signal>> Set MotorStall <<send>> <<exception>> add() Underflow remove() <<send>>
7
State Machine Interaction can model the behavior of a society of objects that work together. State machine can model the behavior of an individual object. A state machine is a behavior that specifies the sequences of states an object goes through during its lifetime in response to events. A state is a condition or situation during the life of an object during which it satisfies some condition, performs some activity, or waits for some event. In the context of state machines, an event is an occurrence of a stimulus that can trigger a state transition. A transition is a relationship between two states indicating that an object in the first state will enter the second state.
8
States Name – a textual string
Entry/exit actions – actions executed on entering and exiting the state Internal transitions – transitions that are handled without causing a change in state Substates – the nested structure of a state Defferred events – a list of events that are not handled in that state but, are postponed and queued for handling by the object in another state Initial and final states
9
Transitions Source state – the state affected by the transition
Event trigger – the event whose reception by the object in the source state makes the transition eligible to fire Guard condition – a boolean expression that is evaluated when the transition is triggered by the reception of the event trigger Action – an executable atomic computation Target state – the state that is after the completion of the transition Note: A change of state is said to fire.
10
Example: time event send signal self-transition triggeriess transition
After (2 seconds) / send c.isAlive self-transition triggeriess transition event trigger noise Idle Searching Engaging event trigger with parameters guard condition targetAt(p) [isThreat] / t.addTarget(p) contact Tracking Engaging action
11
Advanced States Entry & exit actions - actions that always occur upon entry into or exit away from a state regardless of transition. Internal Transitions - triggered by events but don’t change state. Activities - ongoing behavior which continues until interrupted. Deferred events - events ignored by the current state, but postponed for later processing. Tracking entry / setMode( onTrack ) exit / setMode( offTrack ) newTarget / tracker.Acquire() do / followTarget selfTest / defer entry action exit action internal transition activity deferred event name
12
Substates Substate -- state nested inside of another state.
Sequential substates (then a nonorthogonal state) Concurrent substates (then an orthogonal state) composite state sequential substate cardInserted Active Initial state/ pseudostate Idle Validating [continue] cancel Selecting Processing maintain [not continue] fork Idle join Maintenance entry / readCard exit / ejectCard Printing maintain Maintenance composite state Testing Self diagnosis Testing devices H concurrent substate Commanding [continue] Waiting Command H keyPress [not continue]
13
Processes and Threads A process is a heavyweight flow that can execute concurrently with other processes. A thread is a lightweight flow that can execute concurrently with other threads within the same process. An active object is an object that owns a process or thread and can initiate control activity. An active class is a class whose instances are active objects. Graphically, an active class is rendered as a rectangle with thick lines. Processes and threads are rendered as stereotyped active classes.
14
Classes and Events Active classes are just classes which represents an independent flow of control Active classes share the same properties as all other classes. When an active object is created, the associated flow of control is started; when the active object is destroyed, the associated flow of control is terminated two standard stereotypes that apply to active classes are, <<process>> – Specifies a heavyweight flow that can execute concurrently with other processes. (heavyweight means, a thing known to the OS itself and runs in an independent address space) <<thread>> – Specifies a lightweight flow that can execute concurrently with other threads within the same process (lightweight means, known to the OS itself.) All the threads that live in the context of a process are peers of one another
15
Communication In a system with both active and passive objects, there are four possible combinations of interaction First, a message may be passed from one passive object to another Second, a message may be passed from one active object to another In inter-process communication there are two possible styles of communication. First, one active object might synchronously call an operation of another. Second, one active object might asynchronously send a signal or call an operation of another object a synchronous message is rendered as a full arrow and an asynchronous message is rendered as a half arrow
16
Third, a message may be passed from an active object to a passive object
Fourth, a message may be passed from a passive object to an active one
17
Synchronization synchronization means arranging the flow of controls of objects so that mutual exclusion will be guaranteed. in object-oriented systems these objects are treated as a critical region three approaches are there to handle synchronization: Sequential – Callers must coordinate outside the object so that only one flow is in the object at a time Guarded – multiple flow of control is sequentialized with the help of object’s guarded operations. in effect it becomes sequential.
18
Concurrent – multiple flow of control is guaranteed by treating each operation as atomic
synchronization are rendered in the operations of active classes with the help of constraints
19
Modelling Multiple Flows of Control
To model multiple flows of control, · Identify the opportunities for concurrent action and reify each flow as an active class. Generalize common sets of active objects into an active class. Be careful not to overengineer the process view of your system by introducing too much concurrency. · Consider a balanced distribution of responsibilities among these active classes, then examine the other active and passive classes with which each collaborates statically. Ensure that each active class is both tightly cohesive and loosely coupled relative to these neighboring classes and that each has the right set of attributes, operations, and signals. · Capture these static decisions in class diagrams, explicitly highlighting each active class. · Consider how each group of classes collaborates with one another dynamically. Capture those decisions in interaction diagrams. Explicitly show active objects as the root of such flows. Identify each related sequence by identifying it with the name of the active object.
20
Pay close attention to communication among active objects
Pay close attention to communication among active objects. Apply synchronous and asynchronous messaging, as appropriate. Pay close attention to synchronization among these active objects and the passive objects with which they collaborate. Apply sequential, guarded, or concurrent operation semantics, as appropriate.
21
Modelling Interprocess Communication
To model interprocess communication, Model the multiple flows of control. Consider which of these active objects represent processes and which represent threads. Distinguish them using the appropriate stereotype. Model messaging using asynchronous communication; model remote procedure calls using synchronous communication. Informally specify the underlying mechanism for communication by using notes, or more formally by using collaborations.
23
State diagram for Book:
24
State diagram for Librarian:
25
THANK YOU
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.