You are on page 1of 27

Component

Diagrams
This document is for private circulation only,
For Final Year BTech. Computer 2022-23 CCOEW students.

Subject: Software Engineering


ACKNOWLEDGEMENT
• This presentation contains pictures, contents taken
from multiple sources, authors and sites.

• We would like to appreciate and thank the authors,


artists and do not claim any of following work to be
ours, but it has been compiled here to use for
academic purpose only.
Unit 1 – Reference book

• Grady Booch, James Rumbaugh, Ivar Jacobson, 'The


Unified Modeling Language User Guide', Pearson
Education, (2nd Edition) (2008).

- For UML Component Diagram and Deployment


Diagram
Component Diagrams
• Def: 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.

• First, a component is physical. It lives in the world of bits, not concepts.

• Second, a component is replaceable. A component is substitutable. It is


possible to replace a component with another that conforms to the same
interfaces.

•Third, a component is part of a system. A component rarely stands alone.

Rather, a given component can collaborates with other components.


Names
•Every component must have a name that distinguishes it from other
components. A name is a textual string.

•That name alone is known as a simple name; a path name is the


component name prefixed by the name of the package in which that
component lives.

• Just as with classes, you may draw components adorned with tagged
values or with additional compartments to expose their details.
Components and Classes
In many ways, components are like classes:

•Both have names;


•Both may realize a set of interfaces;
•Both may participate in dependency, generalization, and association
relationships;
•Both may be nested;
•Both may have instances;
•Both may be participants in interactions.
•Classes represent logical abstractions; Components
represent physical things that live in the world of bits. In
short, components may live on nodes, classes may not.

•The first difference is the most important. When modeling


a system, deciding if you should use a class or a
component involves a simple decision if the thing you are
modeling lives directly on a node, use a component;
otherwise, use a class.

•There are some significant differences between components and classes.


•Components represent the physical packaging of logical things and are at
a different level of abstraction.

•The second difference suggests a relationship between classes and


components. In particular, a component is the physical implementation of a
set of other logical elements, such as classes and collaborations.
• Classes may have attributes and operations directly. In
general, components only have operations that are
reachable only through their interfaces.

• The third difference points out how interfaces bridge


components and classes. Components and classes may
both realize an interface, but a component's services are
usually available only through its interfaces.
Components and Interfaces
•You can show the relationship between a component and its
interfaces in one of two ways.

•The first (and most common) style renders the interface in


its elided, iconic form. The component that realizes the
interface is connected to the interface using an elided
realization relationship.

•The second style renders the interface in its expanded form,


perhaps revealing its operations. The component that
realizes the interface is connected to the interface using a full
realization relationship.

•In both cases, the component that accesses the services of


the other component through the interface is connected to
the interface using a dependency relationship.
Export Interface & Import Interface
An interface that a component realizes is called an export interface,
meaning an interface that the component provides as a service to other
components. A component may provide many export interfaces.

•The interface that a component uses is called an import interface,


meaning an interface that the component conform to and so builds on. A
component may conform to many import interfaces.

• A component may both import and export interfaces.

•A given interface may be exported by one component and imported by


another. The fact that this interface lies between the two components
breaks the direct dependency between the components.

•A component that uses a given interface will function properly no matter


what component realizes that interface. Of course, a component can be
used in a context if and only if all its import interfaces are provided by the
export interfaces of other components.
Kinds of Components
Three kinds of components may be distinguished.

•First, there are deployment components. These are the components


necessary and sufficient to form an executable system, such as
dynamic libraries (DLLs) and executables (EXEs).

•Second, there are work product components. These components are


essentially the residue of the development process, consisting of
things such as source code files and data files from which
deployment components are created. These components do not
directly participate in an executable system but are the work products
of development that are used to create the executable system.

•Third are execution components. These components are created as a


consequence of an executing system, such as a COM+ object, which
is instantiated from a DLL.
Standard Elements
•All the UML's extensibility mechanisms apply to components.

• Most often, you'll use tagged values to extend component properties


(such as specifying the version of a development component) and
stereotypes to specify new kinds of components
The UML defines five standard stereotypes that apply to components

•Executable :Specifies a component that may be executed on a node

•Library :Specifies a static or dynamic object library

•Table :Specifies a component that represents a database table

•File : Specifies a component that represents a document containing


source code or data

•Document :Specifies a component that represents a document


Standard component stereotypes

Stereotype Semantics

«buildComponent» A component that defines a set of things for organizational or system


level development purposes.

«entity» A persistent information component representing a business concept.

«implementation» A component definition that is not intended to have a specification


itself. Rather, it is an implementation for a separate «specification»
to which it has a dependency.

«specification» A classifier that specifies a domain of objects without defining the


physical implementation of those objects. For example, a Component
stereotyped by «specification» only has provided and required
interfaces - no realizing classifiers.

«process» A transaction based component.

«service» A stateless, functional component (computes a value).

«subsystem» A unit of hierarchical decomposition for large systems.


Component Diagrams
•Component diagrams show a set of components & their relationships.

•Component diagram mainly contain components, interfaces,


dependency ,generalization, association & realization relationships .

•Like all other diagrams , component diagram may contain notes &
constraints.

•Component diagram models the static implementation view of the system.


•Representing Components in UML 2.0

Components are represented as a rectangular classifier with the


keyword «component»; optionally the component may be displayed as a
rectangle with a component icon in the right-hand upper corner .
•Assembly Connector
The assembly connector bridges a component’s required interface
(Component1) with the provided interface of another component
(Component2); this allows one component to provide the services that
another component requires.
Components with Ports

•Using Ports with component diagrams allows for a service or behavior to be


specified to its environment as well as a service or behavior that a component
requires.

•A port is a feature of a classifier that specifies a distinct interaction point


between the classifier and its environment. 

•Ports may specify inputs and outputs as they can operate bi-directionally.
Ports can support unidirectional communication or bi-directional
communication. 

•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.
•The following diagram details a component with a port for online
services along with two provided interfaces order entry and tracking as
well as a required interface payment
The diagram above demonstrates some components and their inter-relationships.
Assembly connectors "link" the provided interfaces supplied by "Product" and "Customer"
to the required interfaces specified by "Order". A dependency relationship maps a
customer's associated account details to the required interface; "Payment", indicated by
"Order
19.13

Using interfaces
• Advantages:
– When we design with classes, we are designing to specific
implementations
– When we design with interfaces, we are instead designing to
contracts which may be realised by many different
implementations (classes)
– Designing to contracts frees our model from implementation
dependencies and thereby increases its flexibility and extensibility
• Disadvantages:
– Interfaces can add flexibility to systems BUT flexibility may lead to
complexity
– Too many interfaces can make a system too flexible!
– Too many interfaces can make a system hard to understand

Keep it simple!
25
19.14

• Interfaces specify a named set of public features:


– They define a contract that classes and subsystems may
realise
– Programming to interfaces rather than to classes reduces
dependencies between the classes and subsystems in our
model
– Programming to interfaces increases flexibility and
extensibility
• Design subsystems and interfaces allow us to:
– Componentize our system
– Define an architecture

26
Online Shopping

• Search Engine component uses IInventory interface to allow


customers to search or browse items. Shopping Cart component
uses Orders component during checkout process. Authentication
component allows customer to login and binds the customer to
Account.

You might also like