Você está na página 1de 16

Component and

Deployment Diagrams

Sources:
Agile Modeling
IBMs Rational Library

Summary Slide

What is a Component Diagram


Component Diagram Example in UML 1.4
Component Diagram Example in UML 2
Basic Notation Used in Component Diagrams
Modeling a Component's Interfaces
Interfaces and Ports
Beyond the Basics
What is a Deployment Diagram
Deployment Diagram Example
UML Deployment Diagram Example
Concise UML 2 Deployment Diagram
Network Diagrams

What is a Component Diagram

The component diagram's main purpose is to show the structural


relationships between the components of a system. [IBM Rational
Libraries]
UML component diagrams are great for identifying the
architectural landscape for your system as they enable you to
model the high-level software components, and more importantly
the interfaces to those components. [Agile Modeling]

Component Diagram Example

A component diagram provides a physical view of the system. Its purpose is to


show the dependencies that the software has on the other software components
(e.g., software libraries) in the system. The diagram can be shown at a very high
level, with just the large-grain components, or it can be shown at the component
package level.
Modeling a component diagram is best described through an example. Figure
below shows four components: Reporting Tool, Billboard Service, Servlet 2.2
API, and JDBC API. The arrowed lines from the Reporting Tool component to
the Billboard Service, Servlet 2.2 API, and JDBC API components mean that the
Reporting Tool is dependent on those three components.

Component Diagram Example in UML 1.4

Component Diagram Example in UML 2

Basic Notation Used in Component Diagrams

Drawing a component in UML 2 is now very similar to drawing a class on a


class diagram. In fact, in UML 2 a component is merely a specialized version of
the class concept. Which means that the notation rules that apply to the class
classifier also apply to the component classifier.
In UML 2, a component is drawn as a rectangle with optional compartments
stacked vertically. A high-level, abstracted view of a component in UML 2 can
be modeled as just a rectangle with the component's name and the component
stereotype text and/or icon. The component stereotype's text is component"
and the component stereotype icon is a rectangle with two smaller rectangles
protruding on its left side (the UML 1.4 notation element for a component).
When drawing a component on a diagram, it is important that you always
include the component stereotype text (the word "component" inside double
angle brackets, as shown in Figure below) and/or icon. The reason? In UML, a
rectangle without any stereotype classifier is interpreted as a class element. The
component stereotype and/or icon distinguishes this rectangle as a component
element.

Modeling a Component's Interfaces

UML 2 has also introduced another way to show a component's provided and
required interfaces. This second way builds off the single rectangle, with the
component's name in it, and places what the UML 2 specification calls interface
symbols" connected to the outside of the rectangle.
In this second approach the interface symbols with a complete circle at their end
represent an interface that the component provides -- this lollipop" symbol is
shorthand for a realization relationship of an interface classifier. Interface symbols
with only a half circle at their end (a.k.a. sockets) represent an interface that the
component requires (in both cases, the interface's name is placed near the interface
symbol itself). For example, the Order component provides two interfaces:
OrderEntry and AccountPayable, and the Order component requires the Person
interface.

Interfaces and Ports

Components may both provide and require interfaces. An interface is the


definition of a collection of one or more methods, and zero or more attributes,
ideally one that defines a cohesive set of behaviors. A provided interface is
modeled using the lollipop notation and a required interface is modeled using the
socket notation. A port is a feature of a classifier that specifies a distinct
interaction point between the classifier and its environment. Ports are depicted
as small squares on the sides of classifiers.
Ports can be named, such as the Security and Data ports on the Student
component.
Ports can support unidirectional communication or bi-directional
communication. The Student component implements three ports, two
unidirectional ports and one bi-directional ports. The left-most port is an input
port, the Security port is an output port, and the Data port is a bi-directional port.

Beyond the Basics

The component diagram is one of the easier-to-understand diagrams,


so there is not much to cover beyond the basics.
There will be times when it makes sense to display a component's
internal structure. To show a component's inner structure, you merely
draw the component larger than normal and place the inner parts
inside the name compartment of the encompassing component. Figure
below, show's the Store's component inner structure.

What is a Deployment Diagram

The deployment diagram shows how a system will be physically deployed in the
hardware environment. Its purpose is to show where the different components of
the system will physically run and how they will communicate with each other.
Since the diagram models the physical runtime, a system's production staff will
make considerable use of this diagram.
The notation in a deployment diagram includes the notation elements used in a
component diagram, with a couple of additions, including the concept of a node.
A node represents either a physical machine or a virtual machine node (e.g., a
mainframe node). To model a node, simply draw a three-dimensional cube with
the name of the node at the top of the cube. Use the naming convention used in
sequence diagrams.

Deployment Diagram Example


The deployment diagram below shows that the users access the Reporting Tool by using a
browser running on their local machine and connecting via HTTP over their company's
intranet to the Reporting Tool. This tool physically runs on the Application Server named
w3reporting.myco.com. The diagram shows the Reporting Tool component drawn inside of
IBM WebSphere, which in turn is drawn inside of the node w3.reporting.myco.com. The
Reporting Tool connects to its reporting database using the Java language to IBM DB2's
JDBC interface, which then communicates to the actual DB2 database running on the server
named db1.myco.com using native DB2 communication. In addition to talking to the
reporting database, the Report Tool component communicates via SOAP over HTTPS to the
Billboard Service.

UML Deployment Diagram Example

The three-dimensional boxes represent nodes, either software or hardware. Physical


nodes should be labeled with the stereotype device, to indicate that it is a physical
device such as a computer or switch.

Connections between nodes are represented with simple lines, and are assigned
stereotypes such as RMI and message bus to indicate the type of connection.

Concise UML 2 Deployment Diagram

A better example is shown in the figure below. Software elements are now simply
listed by their physical filenames, information that developers are very likely to be
interested in, and thus a more compact diagram is possible. A drum is used as a
visual stereotype for the University DB database, making it easier to distinguish on
the diagram. Another difference is that the concise version shows less details, not as
many tagged values are shown as this information can be captured in either
supporting documentation, configuration files, or source code.

Network Diagrams

Network diagrams are often drawn using software-based drawing


tools (figure below was drawn using Microsoft Visio)

Summary Slide

What is a Component Diagram


Component Diagram Example in UML 1.4
Component Diagram Example in UML 2
Basic Notation Used in Component Diagrams
Modeling a Component's Interfaces
Interfaces and Ports
Beyond the Basics
What is a Deployment Diagram
Deployment Diagram Example
UML Deployment Diagram Example
Concise UML 2 Deployment Diagram
Network Diagrams

Você também pode gostar