Domain Partitioning  «Prev  Next»
Lesson 3 Packages
Objective Explain the use of packages to model partitions.

Packages to Model Partitions

Packages provide a generic tool for grouping information and model elements. The contents of a package are entirely user-defined, so packages make a convenient tool for defining partitions. A package may be 1) named and 2) stereotyped, for example:
A package may be 1) named and 2) stereotyped
  1. Dependency arrow: The Sales partition depends on the Show Pricing partition.
  2. Dependency arrow: The Sales partition depends on the Show Pricing partition.
  3. Package name and Stereotype (in label form; stereotypes may also be shown as icons

UML Packages
Packages
The use case model shown in the image contains two packages (or classes), each labeled with a stereotype `<< Domain Partition >>`.
The diagram also shows a dependency relationship between them.
  1. Class/Package 1:
    << Domain Partition >>
    

    Sales
  2. Class/Package 2:
    << Domain Partition >>
    
    Show Management

Relationship:
  1. A "dependency arrow" is drawn from `Sales` to `Show Management`, indicating that:
    Sales depends on Show Management
    

Additional Annotations (not classes but explanatory):
  • Package icon
  • Package name and Stereotype (in label form; stereotypes may also be shown as icons)
  • Dependency arrow: The Sales partition 'depends' on the Show Pricing partition. (Though note: it should probably read "Show Management partition" based on the actual class name in the diagram.)

Packages are UML constructs that enable you to organize model elements into groups, making your UML diagrams simpler and easier to understand. Packages are depicted as file folders and can be used on any of the UML diagrams, although they are most common on use-case diagrams and class diagrams because these models have a tendency to grow.

Packages and Dependencies

A package diagram shows packages and their dependencies. If you have packages for presentation and domain, you have a dependency from the presentation package to the domain package if any class in the presentation package has a dependency to any class in the domain package. In this way, interpackage dependencies summarize the dependencies between their contents. The UML has many varieties of dependency, each with particular semantics and stereotype. I find it easier to begin with the unstereotyped dependency and use the more particular dependencies only if I need to, which I hardly ever do. In a medium to large system, plotting a package diagram can be one of the most valuable things you can do to control the large-scale structure of the system. Ideally, this diagram should be generated from the code base itself, so that you can see what is really there in the system. A good package structure has a clear flow to the dependencies, a concept that is difficult to define but often easier to recognize. Figure 4-3 shows a sample package diagram for an enterprise application, one that is well-structured and has a clear flow.
An order request is sent to the J2EE server
Figure 4-3: An order request is sent to the Java EE server.

If you need some review of packages or package notation, please visit the Resources page and look at the pdf file UML Fundamentals_packages. When you use a package to represent a subsystem, use the <<stereotype>> notation, for example, <<subsystem>>. This notation ensures that your model will be interpreted correctly. Like packages, stereotypes are pretty much up to you to define, but the UML standard does provide some standardized stereotypes.

UML Distilled

UML stereotype Standard Elements

Stereotype Applies to … Meaning
accessclassSpecifies a coherent set of roles that users of use cases play when interacting with these use cases
associationlink endSpecifies that the corresponding object is visible by association
becomemessageSpecifies that the target is the same object as the source but at a later point in time and with possibly different values, state, orroles
copydependencySpecifies that the source a operation invokes the target operation
createevent or messageSpecifies that the target object is an exact but independent copy of the source
derivedependencySpecifies that the source may be computed from the target
destroyevent or messageSpecifies that the target object is destroyed by the event or message
documentcomponentSpecifies a component that represents a document
enumerationclassSpecifies an enumerated type, including its possible values as a set of identifiers
executablecomponentSpecifies a component that may be executed on a node
extenddependencySpecifies that the source use case extends the behavior of the target use case at the given extension point in the target use case
facadepackageSpecifies a package that is only a view on some other package
filecomponentSpecifies a package consisting of mainly patterns
frienddependencySpecifies that the source is given special visibility into the target
globallink endSpecifies that the corresponding object is visible because it is in an enclosing scope
importdependencySpecifies that the public contents of the target package enter the flat namespace of the source, as if they had been declared in thesource
implementationgeneralizationSpecifies that the child inherits the implementation of the parent but does not make public nor support its interface, thereby violatingsubstitutability
implementationclassclassSpecifies the implementation of a class in some programming language
includedependencySpecifies that the source use case explicitly incorporates the behavior of another use case at a location specified by the source
instanceofdependencySpecifies that the source object is an instance of the target classifier
instantiatedependencySpecifies that operations on the source class create instances of the target class
invariantconstraintSpecifies a constraint that must always hold for the associated element
librarycomponentSpecifies a static or dynamic object library
locallink endSpecifies that the corresponding object is visible because it is in a local scope
metaclassclassifierSpecifies a classifier whose objects are classes
parameterlink endSpecifies that the corresponding object is visible because it is a parameter
postconditionconstraintSpecifies a constraint that must hold after the invocation of an operation
powertypeclass or dependencySpecifies a classifier whose objects are all the children of a given parent; specifies that the target is a powertype of the source.
preconditionconstraintSpecifies a constraint that must hold before the invocation of an operation
processclassSpecifies a classifier whose instances represent a heavyweight flow
requirementcommentSpecifies a desired feature, property, or behavior of a system
responsibilitycommentSpecifies a contract by or an obligation of a class
selflink endSpecifies that the corresponding object is visible because it is the dispatcher of the message
senddependencySpecifies that the source operation sends the target event
stereotypeclassSpecifies that the classifier is a stereotype that may be applied to other elements
stubpackageSpecifies a package that serves as a proxy for the public contents of another package
systempackageSpecifies a package representing the entire system being modeled
tablecomponentSpecifies a component that represents a database table
threadclassSpecifies a classifier whose instances represent a lightweight flow of control
typeclassSpecifies an abstract class that is used only to specify the structure and behavior (but not the implementation) of a set of objects
utilityclassSpecifies a class whose attributes and operations are all class-scope

Purpose of Stereotypes

Because of UML 1, many people use the term stereotype to mean the same as keyword, although that is no longer correct.
Stereotypes are used as part of profiles. A profile takes a part of the UML and extends it with a coherent group of stereotypes for a particular purpose, such as business modeling. Unless you are into serious meta-model design, you are unlikely to need to create a stereotype yourself. You are more likely to use one created for a specific modeling purpose, but fortunately, use of a profile does not require you to know all of the details of how they are tied into the meta-model.
  • Packages and subsystem specifications
    Packages may represent subsystems. In fact, "subsystem" is a UML keyword used with packages to specify "a grouping of elements of which some constitute a specification of the behavior offered by the other contained elements." The goal in domain partitioning is to place all of the model elements that define the behavior and the resources for the system into cohesive packages. Each package represents a subsystem, a subset of the complete functionality of the finished system.

Package Dependencies

Relationships between packages are expressed as dependencies[1]. A dependency is described with a dashed arrow and a stereotype or UML keyword. A dependency arrow indicates that the source package requires assistance from the target package, such as access to objects created or maintained by the target package, or functionality owned by the target package. In the booking system, for example, you cannot sell tickets for shows until the seats in the show have been defined and priced.
Apply, Filter, Sort
  1. This subsystem will define the seat locations within the auditorium.
  2. This subsystem tracks which seats are available for sale for each show.
  3. This subsystem assigns prices to seats within each show.

Consequently, the Sales subsystem would depend on the Venue Management, which places the seats within the auditorium. The Sales subsystem would also depend on Show Management, which defines the shows; and Pricing, which assigns the prices to seats in each show.

Sales Subsystem Dependencies

sales subsystem dependencies
Sales subsystem dependencies
You can organize your use case model by functionally related areas (subsystems), by release, or both. One useful strategy is to identify all the use cases within a functional area on the use case diagram, but write the narrative descriptions only for the use cases that will participate in the current release.
  • Create Reusable Subsystems
    Model Based Systems Engineering provides the flexibility and expressiveness to define complex systems quickly effectively by reusing common entities across design projects. A Library is a package containing many reusable subsystems, parametric constraints, common data types and common value types, dimensions and units. The following diagram shows an example library model.
    UML Library
    UML Library

    In the example Library, each of the child packages contains child models that capture the following reusable entities:
    1. Blocks defining systems such as those listed in the Components package, or those defined in the External package.
    2. ConstraintBlocks defining parametric constraints for use in parametric models.
    3. Value Types describing quantities, expressed as measurable dimensions in specific units.
    4. Data Types and Flow Specifications describing data structures and Flows.

Domain Partitioning Packages

Click the Exercise link below to practice what you have learned about domain partitioning and packages.
Domain Partitioning Packages

[1]Dependency: A relationship between two model entities in which a change to one (the independent model element) will affect the other (the dependent model element).

SEMrush Software