Importing and Accessing Packages

When accessing elements in one package from a different package, you must qualify the name of the element you are accessing. For example, if Car is a class in the Transportation package and you are trying to access it from a package named RoutePlanning, you need to qualify Car as Transportation::Car.

To simplify accessing elements in a different package, UML allows a package to import another package. Elements of the imported package are available without qualification in the importing package. So, if the RoutePlanning package imported the Transportation package, you can refer to Car without any qualifications from within the RoutePlanning package.

To show a package import, you draw a dashed line with an open arrow from the importing package to the imported package. Label this line with the «import» keyword. Figure 3-5 shows the RoutePlanning package importing the Transportation package.

RoutePlanning importing the Transportation package

Figure 3-5. RoutePlanning importing the Transportation package

By default, imported elements are given public visibility in the importing package. UML allows you to specify that imported elements should be given private visibility, meaning they can't be used by anyone outside the importing package (including any packages that may import that package). To specify that imported elements should have private visibility, you use the «access» keyword rather than the ...

Get UML 2.0 in a Nutshell 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.