UML 2 For Dummies


Your requirements for a system start out as simple statements from a few users—and before you know it, you have many different types of users, lots of use cases, burgeoning domain terminology, and piles of business rules. As you develop your design solution, you must contend with users’ machines, application servers, Web technology, networking, security, database performance, and a host of other issues. All this results in lots of diagrams and lots of classes to implement. To help you avoid confusion, UML provides packages and subsystems.

A package is an all-purpose way to group things such as classes, use cases, and/or diagrams together—and it’s represented as a tabbed folder. Packages help you keep your development organized. Packages own what’s inside them, and the internal contents of your packages are either public (visible outside the package), private (hidden inside the package), or protected (visible to package extensions, hidden from external packages).

A package can import the contents of another package and then use the imported package contents as if they were inside. You refer to an element like a class that belongs to another package with the PackageName::ElementName notation. For example, Product::AirFilter refers to the AirFilter class owned by the Product package.

 Tip   You use packages to organize your requirements at analysis time. You use subsystems to organize your solution at design time. You can treat subsystems just like packages. In UML 2, subsystems and packages are not exactly the same thing, but they are close enough. (Subsystems are shown as a rectangle with a small fork icon in the upper right-hand corner.)

We use packages and subsystems during analysis and design as follows:

  1. Develop analysis packages.

    During analysis, you can start grouping classes that must work together into the same package. You can also group your use cases by creating a package for each actor and placing the use cases initiated by that actor in the package.

  2. Reorganize packages for system design.

    When you start designing your system, move classes and use cases around to group things together for your developers. Developers appreciate packages organized by important use cases, hardware, development schedule, or department ownership of the information. We’ll give you more details on reorganizing packages later in the chapter.

  3. Convert packages to subsystems.

    Change the packages into subsystems. The subsystems now hold and own, the contents that the packages did. The value of this step comes later when you design the details of each subsystem.

    Not all analysis-time packages turn into subsystems. You might keep a package that holds common datatype definitions during design time. Subsystems in your system import the contents of the datatype package.

  4. Consider dependencies.

    Look at each subsystem and examine how it may (or may not) depend on the contents of other subsystems.

  5. Reorganize subsystems.

    Rearrange the contents of your subsystems to either increase dependencies (for performance) or decrease dependencies (for modularity) among your subsystems. At this stage, you use architectural design patterns such as façade or three-tier to reduce subsystem dependencies and increase the flexibility of your system’s design. (You can find more about façade and three-tier patterns in the section “Using other architectural patterns,” later in this chapter.) Doing so can often lead to a change in how you arrange your subsystems. If you reduce subsystem dependencies, you can have teams of designers work independently on each subsystem.

  6. Design subsystem details.

    After you’re satisfied with the overall organization of your subsystems, then you begin designing their details. UML enables you to show the specification (requirements) and the realization (implementation details) for each subsystem.

 Remember   If you organize your subsystems well, then teams of developers can design each subsystem without worrying about how the other subsystems are designed.

Creating analysis packages

The systems you analyze are probably large and complex with many different types of users, too many classes to remember, and lots of different behavioral interactions among the classes. To keep it all straight, we use packages during analysis. Here are some of the packages we find useful during system and software analysis:

 Tip   You can continue to use packages during the design phase of your project as a general-purpose way of grouping elements from your UML diagrams together. However, we like to use subsystems during design because they allow you to show how specific requirements are realized by a group of cooperating classes.

Figure 20-1 shows some of the packages for an air-filter product business. The order clerk and the clerk’s use cases are owned by the Order Handling package. The Account Billing package contains the accountant actor and use cases directly accessed by the accountant. A separate Analysis Datatype package holds several classes stereotyped as enumerations and a couple of abstract datatypes.

Figure 20-1: Analysis packages for actors, use cases, and datatypes.

The domain packages for the air-filter business example are shown in Figure 20-2. To keep the diagrams simple, we don’t show all classes and associations. You can see some of the classes owned by the Customer Accounting package, but we don’t show the contents of the Supplier Accounting, Airfilter Product, and AirEvents packages. Call it an exercise of a handy UML feature: showing or hiding the contents of a package as needed.

Figure 20-2: Analysis-time packages for problem domain.

Creating subsystems

If your analysis results in a lot of classes and required behavior to make the system or software conform to what your users need, then you need to organize your design using multiple subsystems. During design, you can create subsystems according to the following criteria:

Figure 20-3 shows a group of subsystems based on the analysis-time packages for the air-filter business example. The two analysis-time use-case packages lead to the Order Handling and Billing subsystems. (The Billing subsystem contains the Check Credit Card use instead of Order Handling.)

Figure 20-3: Example of design time subsystems.

At analysis time, all the different domain packages lead to a subsystem that holds all the common objects. The Common Objects subsystem contains several sub-subsystems—Customer, Supplier, and Product. The Persistent Store subsystem provides an interface to a back-end relational database-management system. The Security subsystem handles all login and user authorization tasks. The Accounting System Interface provides access to a legacy accounting system.

 Remember   The Analysis Datatypes package is now called the Domain-Datatypes package for the system design. Not all analysis packages convert to subsystems.


Категории