What is UML Component Diagram? Notations, Example

โšก Smart Summary

UML Component Diagram in OOAD models a large system by breaking it into smaller, manageable subsystems and showing how replaceable components connect through interfaces. This resource explains component notation, ports, subsystems, drawing steps, and a worked example.

  • ๐Ÿงฉ Core Idea: A component diagram splits a large system into smaller, replaceable, and executable subsystems.
  • โฌ› Component: Each component is a black box whose behavior is defined by its provided and required interfaces.
  • ๐Ÿ”Œ Interfaces: Provided and required interfaces connect through an assembly connector to wire components together.
  • ๐Ÿšช Ports: A port is an interaction point that groups a component’s provided and required interfaces.
  • ๐Ÿ› ๏ธ Usage: Component diagrams model structure at runtime and support system testing and subsystem organization.

What is UML Component Diagram

What is Component Diagram in UML?

UML Component Diagrams are used for modeling large systems into smaller subsystems which can be easily managed. UML Component diagrams are used to represent different components of a system. When modeling large object-oriented systems, it is necessary to break down the system into manageable subsystems.

A component is a replaceable and executable piece of a system whose implementation details are hidden. A component provides the set of interfaces that a component realizes or implements. Components also require interfaces to carry out a function.

Component Diagram Notations

Following are the UML Component Diagram Notations:

Component

Component Notation in Component Diagram
Component Notation in Component Diagram

Node

Node Notation in Component Diagram

Node Notation in Component Diagram

What is Component in OOAD?

A Component is a replaceable and executable piece of a system whose implementation details are hidden. A component provides the set of interfaces that a component realizes or implements. Components also require interfaces to carry out a function.

It is a modular part of a system that encapsulates its contents. They are the logical elements of a system that plays an essential role during the execution of a system.

A component is similar to a black box whose external behavior is defined by a provided interface and required interfaces.

Structure of a UML Component

A component is represented with classifier rectangle stereotypes as:

<< component >>: Component details are hidden for the outside world. The name of a component is placed at the center of a rectangle. A component icon is displayed at the upper right corner of a rectangle, which is optional.

A Component in UML is represented as follows:

Structure of a UML Component

Structure of a UML Component

Interface in Component Diagram

The Interface is a named set of public features. It separates the specification of functionality from its implementation by a class diagram or a subsystem. An interface symbol cannot be instantiated. It declares a contract that may be realized by zero or more classifiers such as a class or a subsystem.

Anything that realizes an interface accepts the functionalities of the interface and agrees to abide by the contract defined by the interface.

If the implementation language does not support interfaces the use abstract classes, interfaces are named just like classes, in UpperCamelCase.

There are two types of Interfaces in Component Diagram:

  1. Provided interfaces
  2. Required interfaces

We can connect provided and required interfaces using assembly connector.

Advantages

  • It increases the flexibility and extensibility of a class.
  • It decreases the implementation dependencies.

Disadvantages

  • Extra flexibility leads to complex classes.
  • Too many interfaces make systems hard to understand.

Component Diagram Subsystems

It is a component base that acts as a decomposition unit for larger systems. It is a logical construct which is used to break down an extensive system into smaller systems which are known as subsystems. This process makes it easy to manage each subsystem efficiently.

A subsystem cannot be instantiated during runtime, but their contents can be initialized. When subsystems are connected, it creates a single system.

Port in Component Diagram

A Port is an interaction point between a classifier and an external environment. It groups semantically cohesive set of provided and required interfaces. A port can be used in UML without specifying the name of the port. A port may have visibility. When a port is drawn over the boundary of a classifier, 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 classifier, then it is either protected or private.

A port also has multiplicity that indicates the number of instances of the port classifier will have. A port in UML diagram is denoted as given below:

Port Notation in Component Diagram

Port Notation in Component Diagram

Here, the port1 is drawn over the boundary, which means it has visibility as public.

How to Draw Component Diagram

Here is how you can draw a UML component diagram:

Step 1) A component is nothing but an executable piece of a system. Various components together make a single system. Component diagrams are used widely during the execution phase of any system.

Step 2) Before modeling the component diagram, one must know all the components within the system. The working of each component should be mentioned. Component diagrams are used to analyze the execution of a system.

Step 3) One should also explore each component in depth to understand the connection of a component to other physical artifacts in the system.

Step 4) The relationship amongst various artifacts, libraries, and files are the essential things required during modeling of a component diagram.

UML Component Diagram Example

Below is an example of UML Component Diagram:

UML Component Diagram Example

UML Component Diagram Example

Why use Component Diagram?

UML component diagrams have significant importance. Component diagram variously differs from other diagrams. While other diagrams are used to represent the system, working of a system or the architecture of a system. Component diagrams are used to describe the working and behavior of various components of a system.

It represents how each component acts during the execution of a system.

These are the static diagrams of the unified modeling language. A component diagram is used to represent the structure and organization of components during any instance of time.

Component diagrams are used for modeling the subsystems. These subsystems collectively represent the entire working view of any system. A single component cannot visualize the whole system, but the collection of multiple components can.

So, Component Diagrams are used for:

  • To represent the components of any system at runtime.
  • It helps during testing of a system.
  • It visualizes the connection between various components.

When to use Component Diagram?

Component diagrams are different from any other diagrams in UML. Component diagrams are used to display various components of a software system as well as subsystems of a single system. They are used to represent physical things or components of a system. It generally visualizes the structure and an organization of a system.

It describes how various components together make a single, fully functional system. We can display each component individually or collectively as a single unit.

  1. Component diagrams are used to model the component organization of a system.
  2. They are used to divide a single system into various subsystems as per the functionality.

FAQs

A component diagram shows the software components and their interfaces. A deployment diagram shows the physical hardware nodes and where components run on them. Component diagrams model software structure; deployment diagrams model the runtime hardware environment.

An assembly connector links a required interface of one component to the provided interface of another. It shows that one component supplies a service the other needs, wiring components together into a working system.

The ball (lollipop) symbol represents a provided interface a component offers, and the socket (half-circle) represents a required interface it needs. Fitting the ball into the socket shows one component supplying what another requires.

AI tools can read a system description or module list and suggest a component diagram with components, interfaces, and connectors. This helps architects draft structure faster, though the boundaries and dependencies still need expert review.

Yes. Reverse-engineering and AI tools can scan a codebase, group files into components, and map their interfaces and dependencies into a draft component diagram. Review the output, because AI may miss intended architectural boundaries.

Summarize this post with: