UML: What is Package Diagram? How to use it?

A package is a grouping of model elements which means that a package can contain model elements of different kinds, including other packages to create hierarchies. A package defines a namespace for its contents using for various purposes.

Package Diagram at a Glance

Package diagram is used to simplify complex class diagrams, you can group classes into packages. A package is a collection of logically related UML elements.

The diagram below is a business model in which the classes are grouped into packages:

  • Packages appear as rectangles with small tabs at the top.
  • The package name is on the tab or inside the rectangle.
  • The dotted arrows are dependencies.
  • One package depends on another if changes in the other could possibly force changes in the first.

Basic Concepts of Package Diagram

Package diagram follows hierarchal structure of nested packages. Atomic module for nested package are usually class diagrams. There are few constraints while using package diagrams, they are as follows.

  • Package name should not be the same for a system, however classes inside different packages could have the same name.
  • Packages can include whole diagrams, name of components alone or no components at all.
  • Fully qualified name of a package has the following syntax.

Packages can be represented by the notations with some examples shown below:

Package Diagram — Dependency Notation

There are two sub-types involved in dependency. They are <<import>> & <<access>>. Though there are two stereotypes users can use their own stereotype to represent the type of dependency between two packages.

Key Elements of Package Diagram

Packages are used to organize a large set of model elements:

  • Visibility
  • Import
  • Access

When to Use Packages?

To create an overview of a large set of model elements

  • To organize a large model
  • To group related elements
  • To separate namespaces

Visibility of Packages

Each contained element has a visibility relative to the containing package.

  • A public element is visible to elements outside the package, denoted by ‘+’
  • A protected element is visible only to elements within inheriting packages, denoted by ‘#’
  • A private element is not visible at all to elements outside the package, denoted by ‘-’
  • Same syntax for visibility of attributes and operations in classes

Import Relationship between Packages

The associations are owned by package X:

Import and Access

Inheritance

A package with a generalization to another package inherits public and protected elements that are owned or imported by the inherited package. Packages are shown in static diagrams two equivalent ways to show containment:

Subsystems

Subsystems are used for system decomposition that can be represented by the parts of a system: (Specification / Realization)

Subsystem Internal and External Aspects

A subsystem has a specification and a realization to represent the two views:

  • An external view, showing the services provided by the subsystem
  • An internal view, showing the realization of the subsystem
  • There is a mapping between the two aspects

Modeling Tips of Subsystem

  • Define a subsystem for each separate part of a large system
  • Choose specification technique depending on factors like kind of system and kind of subsystem
  • Realize each subsystem independently, using the specification as a requirements specification

Modeling Complex Grouping

A package diagram is often used to describe the hierarchical relationships (groupings) between packages and other packages or objects. A package represents a namespace.

Package Diagram Example — Layering Structure


Try it your Own and Have Fun with Visual Paradigm Online

Visual Paradigm online (FREE Express Edition)

  • Free Package Diagram examples and templates editable in an online Package Diagram software: Visual Paradigm Online.
  • Use the templates as a starting point to create your own Package Diagram.

Layerd Application

MVC Structure

Stocks Trading System

Ticket Selling System

59 komentarzy

  1. Have you ever thought about adding a little bit more than just your
    articles? I mean, what you say is fundamental and all. Nevertheless think
    of if you added some great pictures or video clips to give your posts more,
    „pop”! Your content is excellent but with images and video clips,
    this blog could undeniably be one of the greatest in its field.
    Awesome blog!

  2. Have you ever considered about including a little bit more than just your articles?
    I mean, what you say is valuable and everything.
    However just imagine if you added some great photos or video clips to give your
    posts more, „pop”! Your content is excellent but with images and video clips,
    this site could certainly be one of the very best in its niche.
    Fantastic blog!

  3. With havin so much content and articles do you ever run into
    any problems of plagorism or copyright infringement?

    My website has a lot of exclusive content I’ve either written myself or outsourced but it looks
    like a lot of it is popping it up all over the internet without my permission. Do you
    know any techniques to help prevent content from being stolen? I’d
    definitely appreciate it.

  4. Its like you learn my mind! You appear to understand a lot about this,
    like you wrote the e book in it or something. I feel that you could
    do with a few % to force the message house a little bit,
    however instead of that, that is excellent blog. An excellent read.
    I will certainly be back.

  5. Undeniably believe that which you said. Your favorite reason seemed to be on the web the simplest thing to be
    aware of. I say to you, I certainly get annoyed while people consider worries that they
    just do not know about. You managed to hit the nail upon the top and also defined out the whole thing
    without having side effect , people could take a signal.
    Will probably be back to get more. Thanks

Leave a Reply

Twój adres e-mail nie zostanie opublikowany.