Architecture · Software

UML Package Diagram

A package – groups together elements of a software that are related. This elements can be related based on Data, Classes, User Tasks.

A package also defines a namespace for the elements it contains, helps to organize the named elements of a software into a separate score. An element can be uniquely identified in the system by a fully qualified name, based on the own name and the name of the package that element is in (namespace).

Package diagram show packages and the dependencies between them. The packageable elements might be: Data, Classes, Other packages. Package diagrams are helpful for when you want a high-level look at your system, how different packages depend on each other.

A package has a simple depiction, which looks like a tabbed folder.

Package.png
A package without details.
Package with details.png
A package with details.
Package with details alternate.png
A package with details alternative interface. (The package contains the interface, its composition)

More detailed package, with access modifiers, should have unique fully qualified names. Only the Audio class available for outside of the package:

More detailed package.png
More detailed package.

The next example shows the Level package importing Location from the player package. This brings the name location into the Level namespace, particularly for convenient use by elements in Level. Also the import tag says the import is public, so this name visible for further import through Level.

Package Import from another package.png
Importing Location from another package.

The diagram also shows the Level package importing data from the Player package. However, the access tag says the import is private. So this name is visible only by elements within the Level namespace and and not further outside.

This diagram shows how a package importing another package:

Package importing another package Diagram.png
Importing another package.

The User Interface package is doing a public import of the Player package, indicated by import tag. Also doing the private import of the Buttons package indicated by the access tag.

This diagram shows how 2 packages are merged into one:

Two packages are merged into one Diagram.png
Two packages merged into one.

Merging is typically done when you have two packages or concepts and you need them merged into a single one. This is a use of generalization that allows you to provide different definitions of the same concept. In video games, both Vendors and Quest-givers are non player characters that provide items, allowing us to merge the two into a Non-player Character package because of their similar functionalities, but slightly different definitions.

Example with various relationships between packages in the system:

Complex Package Diagram.png
Packages with different relationships.

The Package diagram can be created on any stage of the development and can be adjusted overtime.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.