UML Package Diagram Tutorial

A UML package diagram shows dependencies between the packages in the model. It depicts the structure and organization of project in the large scale.

Package Diagram in UML

A package diagram is a structure UML diagram. It depicts the main outline of a model using packages that are usually displayed in hierarchies. It also shows the dependencies between the packages.

Package Diagram in UML
Package Diagram in UML

Package Diagram Overview

UML Package Diagram Oeverview
UML Package Diagram Oeverview

Package Diagram Symbols

Software Ideas Modeler offers tools for the following elements of a package diagram:

  • Package
  • Class
  • Import
  • Access
  • Refine
  • Merge
  • Use
  • Containment

Package

A package is a type of UML element that is used to group and organize related elements, such as classes, interfaces, and other packages, in a logical and meaningful way. A package can define the namespace of the grouped elements. It provides a mechanism for creating a hierarchical structure for the elements of a software system, and for showing the dependencies and relationships between them.

A package is represented by a tabbed folder symbol, with the package name written inside. A package can contain other packages, classes, interfaces, components, and any other UML element. The package can also have relationships with other packages, such as dependencies and generalizations.

The main purpose of a UML package is to provide a way to organize and structure the elements of a software system in a way that makes it easier to understand and navigate. It allows the modeler to create a high-level view of the system, and to focus on specific areas of functionality by drilling down into the details. Packages can also be used to encapsulate and hide the implementation details of a system, making it easier to reason about and maintain.

Package Merge

The package merge is a type of relationship that is used to indicate that the contents of one package are merged into another package. Multiple packages may be merged into a single package. This relationship is represented by a dashed arrow with an open arrowhead pointing from the merged package to the package that is merging its contents. The arrow is labeled with the «merge» stereotype.

Any element within the merged package can be accessed or used as if it were a member of the package that is merging its contents.

The package merge relationship is useful in a number of situations. For example, it can be used to indicate that the contents of a reusable library or framework are being included in a specific project or application, or that the contents of a subsystem are being included in a larger system.

It is important to note that the package merge relationship does not indicate ownership or control, it simply indicates that the contents of the merged package are included within the package that is merging its contents. The merged package can continue to be used and modified independently of the package that is merging its contents.

Package Import

The package import is a type of relationship that is used to indicate that one package relies on elements from another package in order to function correctly. It allows the packaged objects to use classifiers from the imported package with unqualified names in the target package. This relationship is represented by a dashed arrow with an open arrowhead pointing from the dependent package to the package that is being imported. The arrow is annotated with the «import» stereotype.

The relationship expresses that the dependent (importing) package requires access to the elements in the imported package in order to be able to execute its own functionality.

The package import relationship is useful in a number of situations, like when a package uses classes or interfaces from another package, or when a package uses elements from a reusable library or framework. It also can be used when a system is composed of multiple subsystems, and a package of one subsystem needs to import elements from another subsystem package.

Unlike the package merge relationship, the package import relationship does indicate ownership, or control of the contents, it indicates that the dependent package requires access to the imported package elements to execute its functionality, but it does not incorporate the actual elements from the imported package.

Containment

The containment relationship is used to indicate that the containing package is responsible for the contents of the package that is being contained, and that the contained package cannot be used or understood outside of the context of the containing package. This means that the contained package is a part of the containing package, and it cannot exist independently.

This relationship is represented by a solid line connector with a connector head that is a circle with a plus sign. The circle head is connected to the containing package pointing from the package that is being contained.

The containment relationship is useful in a number of situations, like when a system is composed of multiple subsystems, and a package of one subsystem contains a package of another subsystem. It also can be used when a package contains other packages that provide specific functionality, like packages that provide database access or packages that provide user interface functionality.

The containment relationship is a way to organize and structure the packages in a system, making it easier to understand and navigate the system's package hierarchy. It also allows to hide the details of the contained packages, making the system more modular and easier to maintain.

It is important to note that, a package can be contained by only one package, but a package can contain multiple packages.

Use

The use relationship shows which package is publicly used by a package. It is used for depicting the usage of interfaces.

Access

The access relationship shows which package is accessed by a package. It expresses private usage.

How to Draw a Package Diagram?

You can create a new package diagram in multiple ways:

  • Click on a Plus button in the tab switch bar, navigate to the UML group and click on the UML Package Diagram item
  • Press CTRL+SHIFT+D, choose Package Diagram from the UML group, enter the name and click on the OK button.
  • Switch to the Project tab in the ribbon and click on the Package Diagram item in the Content gallery.
  • Open the Project sidebar, right-click on a project (or a folder) node, and in the Add Diagram submenu, choose UML Package Diagram.
Create a new UML package diagram
Create a new UML package diagram

How to Draw Package Diagram Elements?

How to Draw a Package?

  • Click on the Package button in the Package Diagram group in the toolbox.
  • Specify the bounds of the new package by dragging on the diagram canvas.
  • If you want to add a package with the default size, just click on a diagram canvas and the package will be inserted into the specified position.
  • If you want to insert multiple packages in a row, double click (or click twice) on the Package button in the toolbox and draw as many packages as you want in the diagram editor.

How to Draw a Package Merge?

  • Click on the Package Merge button in the Package Diagram group in the toolbox.
  • Drag from one package to another package where the first package should be merged in.
  • Another way you can insert a package merge relationship between two packages is to click on the Package Merge button in the toolbox and drag it in between two packages. The diagram editor shows you which two elements will be connected when you release the button.
  • If you want to insert multiple package merge relationships in a row, double click (or click twice) on the Package Merge button in the toolbox and draw the desired number of package merge relationships in the diagram editor.

How to Draw a Package Import?

  • Click on the Package Import button in the Package Diagram group in the toolbox.
  • Drag from one package to another package where the first package should be imported in.
  • Another way you can insert a package import relationship between two packages is to click on the Package Import button in the toolbox and drag it in between two packages. The diagram editor shows you which two elements will be connected when you release the button.
  • If you want to insert multiple package import relationships in a row, double click (or click twice) on the Package Import button in the toolbox and draw the desired number of package import relationships in the diagram editor.

How to Draw a Use?

  • Click on the Use button in the Package Diagram group in the toolbox.
  • Drag from a package to a publicly used package. The relationship points from a user to a usage.
  • Another way you can insert a use relationship between two packages is to click on the Use button in the toolbox and drag it in between two packages. The diagram editor shows you which two elements will be connected when you release the button.
  • If you want to insert multiple use relationships in a row, double click (or click twice) on the Use button in the toolbox and draw the desired number of use relationships in the diagram editor.

How to Draw an Access?

  • Click on the Access button in the Package Diagram group in the toolbox.
  • Drag from a package to a privately accessed package. The relationship points from an accessor to an accessed package.
  • Another way you can insert an access relationship between two packages is to click on the Access button in the toolbox and drag it in between two packages. The diagram editor shows you which two elements will be connected when you release the button.
  • If you want to insert multiple access relationships in a row, double click (or click twice) on the Access button in the toolbox and draw the desired number of access relationships in the diagram editor.

New Comment

Comment