UML Package Diagram

Package Diagram

package in the  Unified Modeling Language helps

  • To group elements
  • To provide a namespace for the grouped elements
  • A package may contain other packages, thus providing for a hierarchical organization of packages.
  • UML elements can be grouped into packages.

Eg: – classes, objects,use cases, components, nodes, node instances etc.

All UML elements can be organized as packages.

  • UML diagram composed only of packages and the dependencies between them.
  •  A package is a UML construct that enables you to organize model elements, such as use cases or classes, into groups.
  •   Packages are depicted as file folders and can be applied on any UML diagram.

Packages

  • Use a tabbed folder to illustrate packages. Write the name of the package on the tab or inside the folder. Similar to classes, you can also list the attributes of a package

 

  • Each package must have a name that distinguishes it from other packages
  • A name is a textual string
  • Two types of names:
    •  Simple names: e.g., Business rules, Client
    •  Qualified names: e.g. Sensors::Vision
    •  Package name prefixed by the name of the package in which that package lives

Simple and Qualified Names

Create a package diagram to:-

  • Depict a high-level overview of your requirements (overviewing a collection of UML Use Case diagrams)
  • Depict a high-level overview of your architecture/design (overviewing a collection of UML Class diagrams).
  • To logically modularize a complex diagram.

Owned Elements

  • A package may own other elements

–        Classes, interfaces, components, nodes, collaborations, use cases, diagrams, and other packages

  • Ownership is a composite relationship

–        If the package is destroyed, the element is destroyed

–        Every element is uniquely owned by exactly one package

 

Owned Elements and Visibility

  • Visibility

–        Public element is visible to the contents of any package that imports the element’s enclosing package

  • Prefixed the name with a + symbol

–        Protected element can only be seen by children of that package

  • Prefixed the name with a # symbol

–        Private element is not visible outside the package at all

  • Prefixed the name with a – symbol

 

Dependency

  • Dependency defines a relationship in which changes to one package will affect another package. Importing is a type of dependency that grants one package access to the contents of another package.

 

 

 

 

Use Case Package Example

 

  Uses of UML packages

  • Organizing source code, use packages to represent the different layers of the source code.
  1. Presentation layer
  2. Controller layer
  3. Data access layer
  4. Integration layer
  5. Business services layer
  • Organizing component models use packages to group the components according to ownership and/or reuse possibilities. For instance:
  1. Commercial-off-the-shelf products
  2. Framework components
  3. Custom-built framework components
  4. Custom-built application components
  • Organizing deployment models use packages to represent the different types of deployment environments that you will be modeling. For instance:
  1. Production environment
  2. Pre-production environment
  3. Integration test environment
  4. System test environment
  5. Development environment