Ooad Unit-5
Ooad Unit-5
Events and signals, state machines, processes and threads, time and space.
State chart diagrams, component diagrams, deployment diagrams.
Kinds of Events
• Events may be external or internal. External events are those that pass between the system and its
actors.
• For example, the pushing of a button and an interrupt from a collision sensor are both examples
of external events.
• Internal events are those that pass among the objects that live inside the system. An overflow
exception is an example of an internal event.
1. Signal Event
• A signal event represents a named object that is dispatched (thrown) asynchronously by
one object and then received (caught) by another. Exceptions are an example of internal
signal.
• A signal event is an asynchronous event
• Signal events may have instances, generalization relationships, attributes and
operations. Attributes of a signal serve as its parameters.
• A signal event may be sent as the action of a state transition in a state machine or the sending
of a message in an interaction.
• Signals are modeled as stereotyped classes and the relationship between an operation and
the events by using a dependency relationship, stereotyped as send.
Fig: Signals
2. Call Events
• Just as a signal event represents the occurrence of a signal, a call event represents the dispatch
of an operation.
• Whereas a signal is an asynchronous event, a call event is, in general, synchronous.
• It means when an object invokes an operation on another object that has a state machine,
control passes from the sender to the receiver, the transition is triggered by the event, the
operation is completed, the receiver transitions to a new state, and control returns to the sender.
State Machines
States
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. An object remains in a state for a finite amount of time.
A state has several parts.
Name A textual string that distinguishes the state from other states; a state may
be anonymous, meaning that it has no name
Entry/exit actions Actions executed on entering and exiting the state, respectively
Internal Transitions Transitions that are handled without causing a change in state
Deferred A list of events that are not handled in that state but, rather, are
events postponed and queued for handling by the object in another state
Transitions
A transition is a relationship between two states indicating that an object in the first state will perform
certain actions and enter the second state when a specified event occurs and specified conditions are
satisfied. A transition has five parts.
Source state The state affected by the transition; if an object is in the source state, an outgoing
transition may fire when the object receives the trigger event of the transition and if the
guard condition, if any, is satisfied
Event The event whose reception by the object in the source state makes the transition
trigger eligible to fire, providing its guard condition is satisfied
Guard A Boolean expression that is evaluated when the transition is triggered by the reception
condition of the event trigger; if the expression evaluates True, the transition is eligible to fire; if
the expression evaluates False, the transition does not fire and if there is no other
transition that could be triggered by that same event, the event is Lost
Action An executable atomic computation that may directly act on the object that owns the
state machine, and indirectly on other objects that are visible to the object
Target The state that is active after the completion of the transition
state
Event Trigger
• An event is the specification of a significant occurrence that has a location in time and space.
An event is an occurrence of a stimulus that can trigger a state transition.
• A signal or a call may have parameters whose values are available to the transition,
including expressions for the guard condition and action.
Guard
• A guard condition is rendered as a Boolean expression enclosed in square brackets and
placed after the trigger event.
• A guard condition is evaluated only after the trigger event for its transition occurs.
Action
• An action is an executable atomic computation. Actions may include operation calls the
creation or destruction of another object, or the sending of a signal to an object.
Common Modeling Techniques
• Set the context for the state machine, whether it is a class, a use case, or the system as a whole.
• Establish the initial and final states for the object. To guide the rest of your model,
possibly state the pre- and postconditions of the initial and final states, respectively.
• Decide on the events to which this object may respond.
• Starting from the initial state to the final state, lay out the top-level states the object may be
in. Connect these states with transitions triggered by the appropriate events. Continue by
adding actions to these transitions.
• Identify any entry or exit actions (especially if you find that the idiom they cover is used in
the state machine).
• Expand these states as necessary by using substates.
• Check that all actions mentioned in the state machine are sustained by the
relationships, methods, and operations of the enclosing object.
• Check that all actions mentioned in the state machine are sustained by the
relationships, methods, and operations of the enclosing object.
• Trace through the state machine, either manually or by using tools, to check it against
expected sequences of events and their responses. Be especially diligent in looking
for unreachable states and states in which the machine may get stuck.
• After rearranging your state machine, check it against expected sequences again to ensure
that you have not changed the object's semantics.
• 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.
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.
• 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.
Synchronization
• Synchronization means arranging the flow of controls of objects so that mutual exclusion will
be guaranteed.
• 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.
• 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
Common Modeling Techniques
• Identify the opportunities for concurrent action and vreify each flow as an active class. Generalize
common sets of active objects into an active class.
• Capture these static decisions in class diagrams, explicitly highlighting each active class.
• 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. 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.
Time
• Real time systems are, by their very name, time-critical systems.
• Events may happen at regular or irregular times; the response to an event must happen at
predictable absolute times or at predictable times relative to the event itself.
• The passing of messages represents the dynamic aspect of any system, so when you model the
time-critical nature of a system with the UML, you can give a name to each message in an
interaction to be used as a timing mark
• For each event in an interaction, consider whether it must start at some absolute time.
Model that real time property as a timing constraint on the message.
• For each interesting sequence of messages in an interaction, consider whether there is an
associated maximum relative time for that sequence. Model that real time property as a
timing constraint on the sequence.
• For each time critical operation in each class, consider its time complexity. Model those
semantics as timing constraints on the operation
2. Modeling the Distribution of Objects
• For each interesting class of objects in your system, consider its locality of reference. In
other words, consider all its neighbors and their locations. A tightly coupled locality will
have neighboring objects close by
• Next consider patterns of interaction among related sets of objects. Co-locate sets of objects
that have high degrees of interaction, to reduce the cost of communication. Partition sets of
objects that have low degrees of interaction.
• Next consider the distribution of responsibilities across the system. Redistribute your objects
to balance the load of each node.
• Consider also issues of security, volatility, and quality of service, and redistribute your objects
as appropriate.
3. Modeling Objects that Migrate
Statechart Diagrams
• Choose the context for the state machine, whether it is a class, a use case, or the system as a
whole.
• Choose the initial and final states for the object. To guide the rest of your model, possibly state
the pre- and postconditions of the initial and final states, respectively.
• Decide on the stable states of the object by considering the conditions in which the object may
exist for some identifiable period of time. Start with the high-level states of the object and only
then consider its possible substates.
• Decide on the meaningful partial ordering of stable states over the lifetime of the object.
• Decide on the events that may trigger a transition from state to state. Model these events as
triggers to transitions that move from one legal ordering of states to another.
• Attach actions to these transitions (as in a Mealy machine) and/or to these states (as in a Moore
machine).
• Consider ways to simplify your machine by using substates, branches, forks, joins, and history
states.
Fig: Modeling Reactive Objects
• Forward engineering(the creation of code from a model) is possible for statechart diagrams,
especially if the context of the diagram is a class.
• The forward engineering tool must generate the necessary private attributes and final static
constants.
• Reverse engineering (the creation of a model from code) is theoretically possible, but practically
not very useful. The choice of what constitutes a meaningful state is in the eye of the designer.
• Reverse engineering tools have no capacity for abstraction and therefore cannot automatically
produce meaningful statechart diagrams.
A well-structured statechart diagram
Component
• A component is a physical and replaceable part of a system that conforms to and provides the
realization of a set of interfaces. Graphically, a component is rendered as a rectangle with
tabs.
Names
• A component name must be unique within its enclosing package
Binary Replaceability
• The basic intent of every component-based operating system facility is to permit the assembly of
systems from binary replaceable parts.
• This means that you can create a system out of components and then evolve that system by
adding new components and replacing old ones, without rebuilding the system.
• Interfaces are the key to making this happen. When you specify an interface, you can drop into
the executable system any component that conforms to or provides that interface.
• You can extend the system by making the components provide new services through other
interfaces, which, in turn, other components can discover and use. These semantics explain the
intent behind the definition of components in the UML.
Kinds of Components
Organizing Components
• You can organize components by grouping them in packages in the same manner in which
you organize classes.
• The UML defines five standard stereotypes that apply to components
1. executable
2. library
3. table
4. file
5. document
• Identify the partitioning of your physical system. Consider the impact of technical, configuration
management, and reuse issues.
• Model any executables and libraries as components, using the appropriate standard elements. If
your implementation introduces new kinds of components, introduce a new appropriate
stereotype.
• If it's important for you to manage the seams in your system, model the significant interfaces that
some components use and others realize.
• As necessary to communicate your intent, model the relationships among these executables,
libraries, and interfaces. Most often, you'll want to model the dependencies among these parts in
order to visualize the impact of change.
2. Modeling Tables, Files, and Documents
To model tables, files, and documents,
• Identify the ancillary components that are part of the physical implementation of your system.
• Model these things as components. If your implementation introduces new kinds of artifacts,
introduce a new appropriate stereotype.
• As necessary to communicate your intent, model the relationships among these ancillary
components and the other executables, libraries, and interfaces in your system.
• Most often, you'll want to model the dependencies among these parts in order to visualize the
impact of change.
3. Modeling an API
To model an API,
• Identify the programmatic seams in your system and model each seam as an interface, collecting
the attributes and operations that form this edge.
• Expose only those properties of the interface that are important to visualize in the given context;
otherwise, hide these properties, keeping them in the interface's specification for reference, as
necessary.
• Model the realization of each API only insofar as it is important to show the configuration of a
specific implementation.
4. Modeling Source Code
To model source code,
• Depending on the constraints imposed by your development tools, model the files used to store
the details of all your logical elements, along with their compilation dependencies.
• If it's important for you to bolt these models to your configuration management and version
control tools, you'll want to include tagged values, such as version, author, and check in/check out
information, for each file that's under configuration management.
• As far as possible, let your development tools manage the relationships among these files, and use
the UML only to visualize and document these relationships.
Component Diagrams
Contents
Component diagrams commonly contain
• Components
• Interfaces
• Dependency, generalization, association, and realization relationships Like all other
diagrams, component diagrams may contain notes and constraints.
Common uses
• Component diagrams used to model the static implementation view of a system.
• Typically use component diagrams in one of four ways.
1. To model source code
2. To model executable releases
3. To model physical databases
4. To model adaptable systems
• Either by forward or reverse engineering, identify the set of source code files of interest
and model them as components stereotyped as files.
• For larger systems, use packages to show groups of source code files.
• Consider exposing a tagged value indicating such information as the version number of the
source code file, its author, and the date it was last changed. Use tools to manage the value of this
tag.
• Model the compilation dependencies among these files using dependencies. Again, use tools
to help generate and manage these dependencies.
• Identify the classes in your model that represent your logical database schema.
• Select a strategy for mapping these classes to tables. You will also want to consider the physical
distribution of your databases. Your mapping strategy will be affected by the location in which
you want your data to live on your deployed system.
• To visualize, specify, construct, and document your mapping, create a component diagram that
contains components stereotyped as tables.
• Where possible, use tools to help you transform your logical design into a physical design.
4. Modeling Adaptable Systems
• Consider the physical distribution of the components that may migrate from node to node. You
can specify the location of a component instance by marking it with a location tagged value,
which you can then render in a component diagram (although, technically speaking, a diagram
that contains only instances is an object diagram).
• If you want to model the actions that cause a component to migrate, create a corresponding
interaction diagram that contains component instances. You can illustrate a change of location by
drawing the same instance more than once, but with different values for its location tagged value.
• For each component, identify the classes or collaborations that the component implements.
• Choose the target for each component. Your choice is basically between source code (a form that
can be manipulated by development tools) or a binary library or executable (a form that can be
dropped into a running system).
• Use tools to forward engineer your models.
Deployment
• A node is a physical element that exists at run time and represents a computational resource,
generally having at least some memory and, often, processing capability. Graphically, a node is
rendered as a cube.
• Every node must have a name that distinguishes it from other nodes.
• A name is a textual string. That name alone is known as a simple name; a path name is the node
name prefixed by the name of the package in which that node lives.
• A node is typically drawn showing only its name, as in. Just as with classes, you may draw nodes
adorned with tagged values or with additional compartments to expose their details.
• The most common kind of relationship you'll use among nodes is an association. In this
context, an association represents a physical connection among nodes, such as an Ethernet
connection, a serial line, or a shared bus, as Figure .
• Identify the computational elements of your system's deployment view and model each as a node.
• If these elements represent generic processors and devices, then stereotype them as such. If they
are kinds of processors and devices that are part of the vocabulary of your domain, then specify
an appropriate stereotype with an icon for each.
• As with class modeling, consider the attributes and operations that might apply to each node.
Deployment Diagrams
A deployment is a diagram that shows the configuration of run time processing nodes and the
components that live on them. Graphically, a deployment diagram is a collection of vertices and arcs.
Contents
Deployment diagrams commonly contain
• Nodes
• Dependency and association relationships
Like all other diagrams, deployment diagrams may contain notes and constraints
Common Uses
When you model the static deployment view of a system, you'll typically use deployment diagrams in one
of three ways.
1. To model embedded systems 2. To model client/server systems 3. To model fully distributed
systems
• Identify the nodes that represent your system's client and server processors.
• Highlight those devices that are germane to the behavior of your system. For example, you'll want
to model special devices, such as credit card readers, badge readers, and display devices other
than monitors, because their placement in the system's hardware topology are likely to be
architecturally significant.
• Provide visual cues for these processors and devices via stereotyping.
• Model the topology of these nodes in a deployment diagram. Similarly, specify the relationship
between the components in your system's implementation view and the nodes in your system's
deployment view.
• Identify the system's devices and processors as for simpler client/server systems.
• If you need to reason about the performance of the system's network or the impact of changes to
the network, be sure to model these communication devices to the level of detail sufficient to
make these assessments.
• Pay close attention to logical groupings of nodes, which you can specify by using packages.
• Model these devices and processors using deployment diagrams. Where possible, use tools that
discover the topology of your system by walking your system's network.
• If you need to focus on the dynamics of your system, introduce use case diagrams to specify the
kinds of behavior you are interested in, and expand on these use cases with interaction diagrams.
• Choose the target that you want to reverse engineer. In some cases, you'll want to sweep across
your entire network; in others, you can limit your search.
• Choose also the fidelity of your reverse engineering. In some cases, it's sufficient to reverse
engineer just to the level of all the system's processors; in others, you'll want to reverse engineer
the system's networking peripherals, as well.
• Use a tool that walks across your system, discovering its hardware topology. Record that
topology in a deployment model.
• Along the way, you can use similar tools to discover the components that live on each node,
which you can also record in a deployment model. You'll want to use an intelligent search, for
even a basic personal computer can contain gigabytes of components, many of which may not be
relevant to your system.
• Using your modeling tools, create a deployment diagram by querying the model. For example,
you might start with visualizing the basic client/server topology, then expand on the diagram by
populating certain nodes with components of interest that live on them. Expose or hide the details
of the contents of this deployment diagram as necessary to communicate your intent.