Ooad UNIT 5 Notes
Ooad UNIT 5 Notes
Ooad UNIT 5 Notes
State diagrams are used to describe the behavior of a system. State diagrams describe all of the possible
states of an object as events occur. Each diagram usually represents objects of a single class and track the
different states of its objects through the system.
All state diagrams being with an initial state of the object. This is the state of the object when it is
created. After the initial state the object begins changing states. Conditions based on the activities can
determine what the next state the object transitions to.
Below is an example of a state diagram might look like for an Order object. When the object enters the
Checking state it performs the activity "check items." After the activity is completed the object
transitions to the next state based on the conditions [all items available] or [an item is not available]. If an
item is not available the order is canceled. If all items are available then the order is dispatched. When
the object transitions to the Dispatching state the activity "initiate delivery" is performed. After this
activity is complete the object transitions again to the Delivered state.
State diagrams can also show a super-state for the object. A super-state is used when many transitions
lead to the a certain state. Instead of showing all of the transitions from each state to the redundant state a
super-state can be used to show that all of the states inside of the super-state can transition to the
redundant state. This helps make the state diagram easier to read.
The diagram below shows a super-state. Both the Checking and Dispatching states can transition into the
Canceled state, so a transition is shown from a super-state named Active to the state Cancel. By contrast,
the state Dispatching can only transition to the Delivered state, so we show an arrow only from the
Dispatching state to the Delivered state.
Activity Diagrams
Activity diagrams describe the workflow behavior of a system. Activity diagrams are similar to state
diagrams because activities are the state of doing something. The diagrams describe the state of activities
by showing the sequence of activities performed. Activity diagrams can show activities that are
conditional or parallel.
Below is a possible activity diagram for processing an order. The diagram shows the flow of actions in
the system's workflow. Once the order is received the activities split into two parallel sets of activities.
One side fills and sends the order while the other handles the billing. On the Fill Order side, the method
of delivery is decided conditionally. Depending on the condition either the Overnight Delivery activity or
the Regular Delivery activity is performed. Finally the parallel activities combine to close the order.
Physical Diagrams:
There are two types of physical diagrams: deployment diagrams and component diagrams.
Deployment diagrams show the physical relationship between hardware and software in a system.
Component diagrams show the software components of a system and how they are related to each other.
These relationships are called dependencies.
The deployment diagram contains nodes and connections. A node usually represents a piece of hardware
in the system. A connection depicts the communication path used by the hardware to communicate and
usually indicates a method such as TCP/IP.
The component diagram contains components and dependencies. Components represent the physical
packaging of a module of code. The dependencies between the components show how changes made to
one component may affect the other components in the system. Dependencies in a component diagram
are represented by a dashed line between two or more components. Component diagrams can also show
the interfaces used by the components to communicate to each other.
The combined deployment and component diagram below gives a high level physical description of the
completed system. The diagram shows two nodes which represent two machines communicating through
TCP/IP. Component2 is dependent on component1, so changes to component 2 could affect component1.
The diagram also depicts component3 interfacing with component1. This diagram gives the reader a
quick overall view of the entire system.
UML MODELING
It is very important to distinguish between the UML model. Different diagrams are used for different type
of UML modeling. There are three important type of UML modelings:
Structural modeling:
Structural modeling captures the static features of a system. They consist of the followings:
Classes diagrams
Objects diagrams
Deployment diagrams
Package diagrams
Composite structure diagram
Component diagram
Structural model represents the framework for the system and this framework is the place where all other
components exist. So the class diagram, component diagram and deployment diagrams are the part of
structural modeling. They all represent the elements and the mechanism to assemble them. But the
structural model never describes the dynamic behavior of the system. Class diagram is the most widely
used structural diagram.
Behavioral Modeling:
Behavioral model describes the interaction in the system. It represents the interaction among the structural
diagrams. Behavioral modeling shows the dynamic nature of the system. They consist of the following:
Activity diagrams
Interaction diagrams
Use case diagrams
All the above show the dynamic sequence of flow in a system.
Architectural Modeling:
Architectural model represents the overall framework of the system. It contains both structural and
behavioral elements of the system. Architectural model can be defined as the blue print of the entire
system. Package diagram comes under architectural modeling.
A UML Operation contract identifies system state changes when an operation happens. Effectively, it will
define what each system operation does. An operation is taken from a system sequence diagram. It is a
single event from that diagram. A domain model can be used to help generate an operation contract. The
domain model can be marked as follows to help with the operation contract:
Green - Pre existing concepts and associations.
Blue - Created associations and concepts.
Red - Destroyed concepts and associations.
Name: appropriateName
Exceptions: none
When making an operation contract, think of the state of the system before the action (snapshot) and the
state of the system after the action (a second snapshot). The conditions both before and after the action
should be described in the operation contract. Do not describe how the action or state changes were done.
The pre and post conditions describe state, not actions.
Postconditions are described in the past tense. They declare state changes to the system. Fill in the name,
then responsibilities, then postconditions.
Overview:
Deployment diagrams are used to visualize the topology of the physical components of a system where
the software components are deployed.
So deployment diagrams are used to describe the static deployment view of a system. Deployment
diagrams consist of nodes and their relationships.
Purpose:
The name Deployment itself describes the purpose of the diagram. Deployment diagrams are used for
describing the hardware components where software components are deployed. Component diagrams and
deployment diagrams are closely related. Component diagrams are used to describe the components and
deployment diagrams shows how they are deployed in hardware.
UML is mainly designed to focus on software artifacts of a system. But these two diagrams are special
diagrams used to focus on software components and hardware components.
So most of the UML diagrams are used to handle logical components but deployment diagrams are made
to focus on hardware topology of a system. Deployment diagrams are used by the system engineers.
The following deployment diagram is a sample to give an idea of the deployment view of order
management system. Here we have shown nodes as:
Monitor
Modem
Caching server
Server
The application is assumed to be a web based application which is deployed in a clustered environment
using server 1, server 2 and server 3. The user is connecting to the application using internet. The control
is flowing from the caching server to the clustered environment.
So the following deployment diagram has been drawn considering all the points mentioned above:
Software applications are developed to model complex business processes. Only efficient software
applications are not sufficient to meet business requirements. Business requirements can be described as
to support increasing number of users, quick response time etc.
To meet these types of requirements hardware components should be designed efficiently and in a cost
effective way.
Now a day's software applications are very complex in nature. Software applications can be stand alone,
web based, distributed, mainframe based and many more. So it is very important to design the hardware
components efficiently.
Deployment Diagrams
Deployment diagram shows execution architecture of systems that represe nt the assignment
(deployment) of software artifacts to deployment targets (usually nodes).
Nodes represent either hardware devices or software execution environments. They could be
connected through communication paths to create network systems of arbitrary complexity.
Artifacts represent concrete elements in the physical world that are the result of a development
process and are deployed on nodes.
Note, that components were directly deployed to nodes in UML 1.x deployment diagrams. In
UML 2.x artifacts are deployed to nodes, and artifacts could manifest components. So
components are now deployed to nodes indirectly through artifacts.
The following nodes and edges are typically drawn in a UML deployment diagram: artifact,
association between artifacts, dependency between artifacts, component, manifestation, node,
device, execution environment, composition of nodes, communication path, deployment
specification, deployment specification dependency, deployment specification association,
deployment.
You can find some deployment diagrams examples here:
Web Application Deployment
Clustered Deployment of J2EE Web Application
Apple iTunes Deployment
Artifact
An artifact is a classifier that represents some physical entity, piece of information that is used
or is produced by a software development process, or by deployment and operation of a system.
Artifact is source of a deployment to a node. A particular instance (or "copy") of an artifact is
deployed to a node instance.
Artifacts may have prope rties that represent features of the artifact, and operations that can be
performed on its instances. Artifacts have fileName attribute - a concrete name that is used to
refer to the artifact in a physical context - e.g. file name or URI.
Some real life examples of artifacts are:
model file
source file
script
binary executable file
text document
mail message
table in a database
The UML Standard Profile defines several standard stereotypes that apply to artifacts:
«file» A physical file in the context of the system developed.
Standard stereotypes - subclasses of «file»:
«document» A generic file that is not a «source» file or «executable».
«source» A source file that can be compiled into an executable file.
«library» A static or dynamic library file.
«executable» A program file that can be executed on a computer system.
«script» A script file that can be interpreted by a computer system.
Powered by www.technoscriptz.com Page 10
OOAD UNIT 5 6 SEM CSE ANNA UNIVERSITY
Artifact web-app.war
Library commons.dll
Alternatively, artifact may be depicted by an icon.
EJB component UserService and skeleton of web services are manifested by EJB module user-
service.jar artifact
Powered by www.technoscriptz.com Page 12
OOAD UNIT 5 6 SEM CSE ANNA UNIVERSITY
In UML 1.x, the concept of manifestation was referred to as implementation and annotated as
«imple ment». Since this was one of the many uses of the word "implementation" this has been
replaced in UML 2.x by «manifest».
Deployment Target
Artifacts are deployed to deployment targets. Deployme nt target is the location for a deployed
artifact.
Deployment target owns the set of deployment that target it.
Deployment target is specialized by:
node
property
Instance specification was extended in UML 2.0 to allow instance of a node to be deployment
target in a deployment relationship.
Property was also extended in UML 2.0 with the capability of being a deployment target in a
deployment relationship. This enables modeling the deployment to hierarchical nodes that have
properties functioning as internal parts.
Deployment target has no specific notation by itself, see notations for subclasses.
Node
A Node is a deployment target which represents computational resource upon which artifacts
may be deployed for execution.
A Node is shown as a perspective, 3-dimensional view of a cube.
Execution Environment
An execution environment is a node that offers an execution environment for specific types of
component that are deployed on it in the form of executable artifacts. Components of the
appropriate type are deployed to specific execution environment nodes.
Execution environment implements a standard set of services that components require at
execution time (at the modeling level these services are usually implicit). For each deployment
of component, aspects of these services may be determined by properties in a deployment
specification for a particular kind of execution environment.
Execution environment is notated as a node (perspective, 3-dimensional view of a cube)
annotated with the standard stereotype «executionEnvironme nt».
«web server»
«web browser»
Composition of Nodes
Nodes may have an internal structure defined in terms of parts and connectors associated with
them for advanced modeling applications. Parts of node could be only of type node.
Hierarchical nodes (i.e., nodes within nodes) can be modeled using composite associations, or
by defining an internal structure for advanced modeling applications.
Application server box runs several web servers and J2EE serve rs
Execution environment is usually part of a general node or «device» which represents the
physical hardware environment on which this execution environment resides. Execution
environments can be nested (e.g., a database execution environment may be nested in an
operating system execution environment).
Communication Path
A communication path is an association between two deployme nt targets, through which they
are able to exchange signals and messages.
Communication path is notated as association, and it has no additional notation compared to
association.
Deployment
A deployme nt is dependency relationship which describes allocation of an artifact or artifact
instance to a de ployment target.
Accordingly, deployed artifact is an artifact or artifact instance that has been deployed to a
deployment target.
A component deployme nt is the deployment of one or more artifacts or artifact instances to a
deployment target, optionally parameterized by a deployment specification. Examples are
executables and configuration files.
The deployment relationship between a deployed artifact and a deployment target can be defined
at the “type” level and at the “instance level.”
For example, a „type level‟ deployment relationship can be defined between an “application
server” Node and an “order entry request handler” executable Artifact. At the „instance level‟ 3
specific instances “appserver1” ... “app-server3” may be the deployment target for six “request
handler*” instances.
For modeling complex deployment target models consisting of nodes with a composite structure
defined through „parts,‟ a Property (that functions as a part) may also be the target of a
deployment.
Deployment diagram shows deployed artifacts contained within a deployme nt target symbol.
Design Codes
In this post we‟ll see how deployment diagrams are used to model the physical architecture of a
system; we‟ll start from the most simple use of the deployment diagram in which we only
present the nodes and their inter-relationships, and complete the picture by including the
components and the applications that run in the nodes.
Notice that the client node is stereotyped as „pc-client‟ (indicated by the icon) and the server
node is stereotyped as „pc-server‟.
The following diagram shows the deployment architecture of a scalable, fault tolerant „Camera
control and image processing‟ system . The system consist of N servers, load balancer with
redundancy, and several clients.
The client machines present live state of all the cameras available in the system, and allow the
user to control the cameras and initiate all kind of activities on the servers. The load balancer
process the inputs that it receives from the clients and send the appropriate instructions to the
appropriate server, it is designed to gracefully scale to increasing number of servers. Since the
load balancer is a single point of failure, a passive load balancer (that maintains copy of the
active load balancer state) run in the background, ready to replace the active load balancer in
case of a crush. All the servers run the same application, they support different kinds of cameras
and can be configured to manage up to 200 cameras of different kinds.
As you can see the client node includes the „CamerasC2C.Client‟ component which uses
infrastructure level controls reside within „Company.Contorls‟ which includes classes which
derive from framework level controls (notice the use of stereotypes to divide the components to
levels/layers). The „CamerasC2C.Client‟ component communicate with the load balancer
„CamerasC2C.LoadBalance‟ component, which transfer instructions to the appropriate server
through the „IServer‟ interface. The server consist of 3rd party components that were shipped
with the cameras hardware, each component exposes interface tho ugh which the camera can be
Overview:
Component diagrams are different in terms of nature and behaviour. Component diagrams are used to
model physical aspects of a system.
Now the question is what are these physical aspects? Physical aspects are the elements like executables,
libraries, files, documents etc which resides in a node.
So component diagrams are used to visualize the organization and relationships among components in a
system. These diagrams are also used to make executable systems.
Purpose:
Component diagram is a special kind of diagram in UML. The purpose is also different from all other
diagrams discussed so far. It does not describe the functionality of the system but it describes the
components used to make those functionalities. So from that point component diagrams are used to
visualize the physical components in a system. These components are libraries, packages, files etc.
Component diagrams can also be described as a static implementation view of a system. Static
implementation represents the organization of the components at a particular moment.
A single component diagram cannot represent the entire system but a collection of diagrams are used to
represent the whole.
Initially the system is designed using different UML diagrams and then when the artifacts are re ady
component diagrams are used to get an idea of the implementation. This diagram is very important
because without it the application cannot be implemented efficiently. A well prepared component diagram
is also important for other aspects like application performance, maintenance etc.
So before drawing a component diagram the following artifacts are to be identified clearly:
Files used in the system.
Libraries and other artifacts relevant to the application.
Relationships among the artifacts.
Now after identifying the artifacts the following points needs to be followed:
Use a meaningful name to identify the component for which the diagram is to be drawn.
Prepare a mental layout before producing using tools.
Use notes for clarifying important points.
The following is a component diagram for order management system. Here the artifacts are files. So the
diagram shows the files in the application and their relationships. In actual the component diagram also
contains dlls, libraries, folders etc. In the following diagram four files are identified and their relationships
are produced. Component diagram cannot be matched directly with other UML diagrams discussed so far.
Because it is drawn for completely different purpose.
So the following component diagram has been drawn considering all the points mentioned above:
These diagrams show the physical components of a system. To clarify it, we can say that component
diagrams describe the organization of the components in a system. Organization can be further described
as the location of the components in a system. These components are organized in a special way to meet
the system requirements.
As we have already discussed those components are libraries, files, executables etc. Now before
implementing the application these components are to be organized. This component organization is also
designed separately as a part of project execution.
Component diagrams are very important from implementation perspective. So the implementation team
of an application should have a proper knowledge of the component details.
Now the usage of component diagrams can be described as:
Model the components of a system.
Model database schema.
Model executables of an application.
Model system's source code.
Component
A component is a physical building block of the system. It is represented as a rectangle with tabs.
Learn how to resize grouped objects like components.
Powered by www.technoscriptz.com Page 27
OOAD UNIT 5 6 SEM CSE ANNA UNIVERSITY
Interface
An interface describes a group of operations used or created by components.
Dependencies
Draw dependencies among components using dashed arrows.
Learn about line styles in SmartDraw.
Rectangle: A single component is described using a rectangle and having the component‟s name
inside it. <<Component>>Component Name
Additional compartments: Additional compartments are stacked below the component name.
Inte rfaces provided/required: Another compartment exists for displaying the interface
provided and required by the component.
Relationships: A lollipop and socket notation is used along with showing dependency arrows.
Dependency arrow points towards the needed socket and arrowhead connects with provider‟s
lollipop.