UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory UML Weekend Crash Course™ - To Parent Directory

crnarupa.singidunum.ac.rs
from crnarupa.singidunum.ac.rs More from this publisher
01.01.2015 Views

Session 24—Modeling the Development Environment 247 Defining the Notation for Packages and Package Diagrams The package icon looks like a tabbed folder. Packages reference one another using the dependency notation, a dashed arrow. Read the example in Figure 24-2 as “the Receiving subsystem depends on, or needs help from, the Purchasing subsystem package.” Purchasing Receiving Figure 24-2 Package icon and dependency notation Package stereotypes In Figures 24-1 and 24-2, each package icon contains a stereotype like or . You can put almost anything you want in a package, so the package description often requires a bit of clarification. The stereotype allows you to characterize the contents of the package and still provide specific naming of its contents. For example, the Receiving package is characterized as a subsystem. This prevents us from interpreting it as the directory containing the receiving documents, or some other resources besides the subsystem classes. Be careful though. Stereotypes are not part of the package name, so they do not help make it unique. Two packages at the same level called Receiving and Receiving would be in conflict and probably would not be allowed by most modeling tools. On the other hand, if the packages themselves are contained within other packages, then they are qualified by their containers, making them unique. However, you need to check how your modeling tool implements these rules. Package dependency Figure 24-2 also shows a dashed dependency arrow from Receiving to Purchasing. The dependency relationship means that at least one class in a package has to communicate with at least one class in the other package. The dependency in Figure 24-2 could mean that the Receipt class in the Receiving package (Receiving :: Receipt) needs to be able to get the details of the PurchaseOrder class in the Purchasing package (Purchasing :: PurchaseOrder) in order to validate incoming products. It is entirely valid for a dependency to run both directions, indicated by an arrowhead on both ends of the dashed line. Figure 24-3 shows an example where Shipping might need to update an Order in the Order Processing subsystem. But Order Processing might also need to check the status of a Shipment containing the Products on an Order.

248 Sunday Morning Shipping Order Processing Figure 24-3 A bi-directional dependency For simplicity’s sake, all the other dependencies illustrated in this session go only one direction. Dependency stereotypes The package dependency may be labeled with a stereotype to describe the nature of the dependency. The UML defines two dependency stereotypes, and . The stereotype in Figure 24-4 means that the Receiving package adds a Purchasing class (in this case the PurchaseOrder class) to itself at run time, allowing internal references (references within the package) to the class without specifying the source package name. Purchasing Receiving Figure 24-4 The stereotype on a dependency Tip For Java programmers, the stereotype has the same effect as the import statement in Java. The stereotype in Figure 24-5 says that the Shipping subsystem will want to communicate with the Receiving subsystem but will not actually pull the classes from Receiving into Shipping at run time. At run time, you would then expect to see some object from the Shipping subsystem making calls in the interface of the Receiving subsystem. Receiving Shipping Figure 24-5 The stereotype on a dependency Tip There are a number of other stereotypes described in the UML specification in the file 01-09-78 UML 1.4 Appendix A UML Standard Elements.pdf.

Session 24—Modeling the Development Environment 247<br />

Defining the Notation for Packages and Package Diagrams<br />

The package icon looks like a tabbed folder. Packages reference one another using the<br />

dependency notation, a dashed arrow. Read the example in Figure 24-2 as “the Receiving<br />

subsystem depends on, or needs help from, the Purchasing subsystem package.”<br />

<br />

Purchasing<br />

<br />

Receiving<br />

Figure 24-2<br />

Package icon and dependency notation<br />

Package stereotypes<br />

In Figures 24-1 and 24-2, each package icon contains a stereotype like or<br />

. You can put almost anything you want in a package, so the package<br />

description often requires a bit of clarification. The stereotype allows you to characterize<br />

the contents of the package and still provide specific naming of its contents. For example,<br />

the Receiving package is characterized as a subsystem. This prevents us from interpreting it<br />

as the directory containing the receiving documents, or some other resources besides the<br />

subsystem classes.<br />

Be careful though. Stereotypes are not part of the package name, so they do not help<br />

make it unique. Two packages at the same level called Receiving and<br />

Receiving would be in conflict and probably would not be allowed by most<br />

modeling tools. On the other hand, if the packages themselves are contained within other<br />

packages, then they are qualified by their containers, making them unique. However, you<br />

need to check how your modeling tool implements these rules.<br />

Package dependency<br />

Figure 24-2 also shows a dashed dependency arrow from Receiving to Purchasing. The<br />

dependency relationship means that at least one class in a package has to communicate<br />

with at least one class in the other package. The dependency in Figure 24-2 could mean<br />

that the Receipt class in the Receiving package (Receiving :: Receipt) needs to be able to<br />

get the details of the PurchaseOrder class in the Purchasing package (Purchasing ::<br />

PurchaseOrder) in order to validate incoming products.<br />

It is entirely valid for a dependency to run both directions, indicated by an arrowhead on<br />

both ends of the dashed line. Figure 24-3 shows an example where Shipping might need to<br />

update an Order in the Order Processing subsystem. But Order Processing might also need to<br />

check the status of a Shipment containing the Products on an Order.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!