UML Model Organization with Packages and the Package Diagram
Join the DZone community and get the full member experience.Join For Free
it is no coincidence that the package element in uml is represented by a folder icon, similar to directories in a file system graphical user interface (gui). packages are used to organize the elements of a model just as folders are used to organize files. the contents of a package are any kind of element that is part of a model, including other packages. beyond that description there’s not much more information on how to use packages in the uml specification. since they are a general grouping thing, it is up to usage scenarios to suggest what the best practices are for using packages. there are some practices that apply in most situations, and more that depend upon the modeling methodology or the purpose of the model.
first and foremost, use packages to organize your model, regardless of the model purpose. even the most trivial model quickly becomes unmanageable without some kind of organization. there is no single correct way to organize a model. a modeler may choose to organize around process or product or some combination of the two. second, use the package diagram to provide visualizations of that organization. the model browser view below illustrates how even a simple model can begin to be confusing with no organization of the model elements.
|a model with no organizing principle applied|
|the same model with an organizing principle applied|
in addition to being able to gather like items together to allow modelers to focus their attention on relevant elements and make those elements easier to find in the browser, packages provide a namespace for the elements they contain. namespaces allow modelers to create unambiguous named references to each of the elements in a model. this is useful in situations such as when a modeler is evolving a system and creating an as-is and a to-be system model. it is natural to have elements named the same in each model. in order to disambiguate elements with the same name, they can be placed in different packages so that the fully-qualified names are different.
packages can be placed on a uml package diagram. the modeler might choose to do this to present a high-level view of a model or to show relationships among the packages of elements. three different package diagrams representing the model organization shown above are presented here. each of these diagrams uses the optional diagram frame, showing the diagram type (pkg) and diagram name (use case view). note that although the diagram and the package have the same name (use case view) this is not required. in the first diagram, the two high-level packages are shown. as with many other modeling situations, only the details we need are presented, and the details of the package contents are elided.
in the second diagram, the packages contained in the actors package are shown. the labels on the human and non-human package describe the namespace of the containing package. the containment relationship also serves to describe the namespace. in this example, the fully qualified name of the actor operator is use case view::actors::human::operator .
in the third diagram, the contents of the packages are shown embedded in the package elements. this representation is the third presentation option found in the uml specification.
your package diagrams will in all likelihood be some combination of each of these styles, as will your choice of organizing principles. choose the one that is appropriate for its intended use.
if you want to print this article there is a pdf attachment on the sparx community site - model organization with packages
Published at DZone with permission of J.d. Baker, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Build a Simple Chat Server With gRPC in .Net Core
Front-End: Cache Strategies You Should Know
How To Backup and Restore a PostgreSQL Database
Guide To Selecting the Right GitOps Tool - Argo CD or Flux CD