Chapter 13. Organizing Your Model: Packages

As a software program grows in complexity, it can easily contain hundreds of classes. If you’re a programmer working with such a class library, how do you make sense of it? One way to impose structure is by organizing your classes into logically related groups. Classes concerned with an application’s user interface can belong to one group, and utility classes can belong to another.

In UML, groups of classes are modeled with packages . Most object-oriented languages have an analog of UML packages to organize and avoid name collision among classes. For example, Java has packages, C# has namespaces (although Java packages, and C# namespaces differ significantly in other details). You can use UML packages to model these structures.

Package diagrams are often used to view dependencies among packages. Since a package can break if another package on which it depends changes, understanding dependencies between packages is vital to the stability of your software.

Packages can organize almost any UML element—not just classes. For example, packages are also commonly used to group use cases. Package diagrams form part of the development view, which is concerned with how your system’s parts are organized into modules and packages, as shown in Figure 13-1.

The Development View describes how your system’s parts are organized into modules, which are represented as packages in UML
Figure 13-1. The Development View describes how your system’s parts are organized into modules, which ...

Get Learning UML 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.