Lecture 06 Component Diagram Updated
Lecture 06 Component Diagram Updated
1
Component Diagrams
• UML component diagrams describe software components and
their dependencies to each others
• Models the physical implementation of the software (file
resources)
• Models the high-level software components, and their
interfaces
• We use component diagrams to model the static
implementation view of a software system.
• It is a type of structural UML diagram
2
What is a Component
• Modular unit with well-defined interfaces that is replaceable
within its environment
• Autonomous unit within a system
• Has one or more provided and required interfaces
• Its internals are encapsulated, hidden and inaccessible
• Its dependencies are designed such that it can be treated as
independently as possible
• The components can be a software component such as a
database or user interface; or a hardware component such as a
circuit, microchip or device; or a business unit such as supplier,
payroll or shipping.
3
Component Notation
1) Rectangle with the component stereotype (the
text <<component>>). The component stereotype
is usually used above the component name to avoid
confusing the shape with a class icon.Components
can be labelled with a number of standard
stereotypes
ex: <<entity>>,
<<subsystem>>,<<table>>,<<library>>, etc
4
Component Elements
1. Interfaces
An interface represents a declaration of a set of operations and
obligations
2. Usage dependencies
A usage dependency is relationship which one element requires
another element for its full implementation
3. Ports
Port represents an interaction point between a component and its
environment
4. Connectors
Connect two components through interface.
5
INTERFACE
• A component defines its behaviour in terms of provided and
required interfaces
• An interface
• Is the definition of a collection of one or more operations
• Provides only the operations but not the implementation
• Implementation is normally provided by a class/ component
• In complex systems, the physical implementation is provided by a group
of classes rather than a single class
• 2 types
• Provided Interface
• Required interface
6
INTERFACE
Provided Interface
• A component's provided interface
describes the services provided by the
component.
• Is modeled using a ball, labelled with the
name, attached by a solid line to the
component
Required Interface
• A required interface declares the services a
component will need.
• Is modeled using a socket, labelled with
the name, attached by a solid line to the
component
7
INTERFACE
Where two components/classes provide and require the same
interface, these two notations may be combined
8
Usage Dependency
• A usage dependency is relationship which one element requires
another element for its full implementation
• Is a dependency in which the client requires the presence of the
supplier
• Is shown as dashed arrow with a <> keyword
• The arrowhead point from the dependent component to the one
of which it is dependent
9
Port
Specifies a distinct interaction point
• Between that component and its environment
• Between that component and its internal parts
• port may have visibility. When a port is drawn over the
boundary of a component, then it means that the port is public.
It also means that all the interfaces used are made as public.
• When a port is drawn inside the component, then it is either
protected or private.
10
11
Connector
Two kinds of connectors:
• Assembly
• Delegation
ASSEMBLY CONNECTOR
• A connector between 2 components defines that one
component provides the services that another component
requires
• An assembly connector is notated by a “ball-and-socket”
connection
12
Multiple connections directed from a single required interface to
provided interfaces indicates that the instance that will handle the
signal will be determined at execution time
13
DELEGATION CONNECTOR
• Links the external contract of a component to the internal
component
• Represents the forwarding of signals
• It must only be defined between used interfaces or ports of the
same kind
14
Dependency Relation
One component is dependent on data from another component
<<component
>>
<<database
>>
<<component
>>
15
Here the payment interface depends on data from Account
Component for it’s full implementation. The dependency maps a
customer's associated account details to the required interface
"Payment"
16
Where to use
• To model the component of the system
• To model source code
• To model executable releases
• To model physical databases
• To model adaptable systems
17
Order Processing System Component
diagram example
Here the Storefront component
provides interfaces for Order and
ProductDetails. CustomerService
implements this interface as this
component needs access to
ProductDetails of the products available in storefront. Again
CustomerService is able to order and override orders. All these
operations are handled by the Orderprocessor component. Then
this component provide Customer data to analytics component
and shipping data to the shipping component
18
Nested Component Structure
Here the Store component has
some components inside it. In
such cases delegation connector
and port is used to pass signal
from external component to the
internal ones. Here we see that
Customer component requires the account and and Order
component provides order entry related functionalities from an
external component.
19
Some more examples
20
21
22
Life Care Hospital is a renowned hospital that uses a simple hospital management system
named Life Care hospital management. The XYZ hospital management component is
dependent on the access of data from four components: Hospital, Patient, Doctor, and Nurse.
These four components provide an interface named readData. There is another component
named Appointment which provides two interfaces setAppointment and
getAppointmentDetails. The Hospital, Patient and Doctor component implements the
getAppointmentDetails interface while the Receptionist component implements the
setAppointment interface. There are three more components named Synchronization,
Database and Security. The dbConnector interface is provided by and required by Database
and Synchronization components respectively. Both Security and Synchronization
Components provide three crucial interfaces; accessControl, Encryption, and Decryption
which are required by all of the components except XYZ hospital management and the
Database component.
Now Design a component diagram based on the above scenario.
WebStore subsystem contains three components related to online
shopping - Search Engine, Shopping Cart, and Authentication.
Search Engine component allows to search or browse items by
exposing provided interface Product Search and uses required
interface Search Inventory provided by Inventory component.
Shopping Cart component uses Manage Orders interface provided
by Orders component during checkout. Authentication component
allows customers to create account, login, or logout and binds
customer to some account.