Package Diagram: Lab Lect#15 31/7/2020

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

PACKAGE

DIAGRAM

LAB LECT#15
31/7/2020
PACKAGE DIAGRAM

◼ Package diagram shows the arrangement and organization of model elements in


middle to large scale project that can be used to show both structure and dependencies
between sub-systems or modules.
WHAT IS A PACKAGE DIAGRAM IN UML?

A package in the Unified Modeling Language helps:


◼ To group elements
◼ To provide a namespace for the grouped elements
◼ A package may contain other packages, thus providing for a hierarchical organization
of packages.
◼ UML elements can be grouped into packages.
PACKAGE DIAGRAM TO REPRESENT THE COMPOSITION OF A
BUSINESS
PACKAGE DIAGRAM NOTATIONS

◼ Package diagrams are used to structure high level systems.


◼ Packages are used for organizing large system which contains diagrams, documents
and other key deliverables.
◼ In other words, packages can be used as a part of other diagrams also.
1. NESTED AND HIERARCHICAL PACKAGES

◼ A package can be represented as a hierarchical structure with nested packages.


Atomic module for nested package are usually class diagrams.
NESTED PACKAGES
CONSTRAINTS WHILE USING PACKAGE DIAGRAM

1. The name of packages should be unique within a system. However, it is allowed for
classes inside different packages to have same name. For Example, Package::Product &
Shipping::Product are allowed.
2. Users should avoid using package name delivered by the programming language. For
Example, Java provides Date as a package. So, programmers should construct package
with name Date.
3. Packages can include whole diagrams, name of components alone or no components
at all.
A PACKAGE CAN ALSO HAS A FULLY QUALIFIED NAME
CONT…

Note That:
◼ UML, C++, Perl, Ruby myPkg::foo::bar
◼ Java, C# myPkg.foo.bar
PACKAGE CONTAINMENT

◼ Packages are shown in static diagrams


◼ There are two ways to show containment.
CONTAINMENT
DEPENDENCY

There are two sub-types involved in dependency.


◼ <<access>>
◼ <<import>>
◼ Though there are two stereotypes users can use their own stereotype to represent the
type of dependency between two packages.
IMPORT

◼ <<import>> - one package imports the functionality of other package


IMPORT EXAMPLE
ACCESS

◼ <<access>> - one package requires help from functions of other package


WHEN TO DRAW PACKAGE DIAGRAM?

The UML does not treat package diagrams as a separate technique, It is often useful to combine them by
grouping other model elements together into different packages on the same diagram.
Package diagrams can be useful in many ways, such as:
◼ To create an overview of a large set of model elements
◼ To organize a large model
◼ To group related elements
◼ To separate namespaces
CRITERIA FOR DECOMPOSING A SYSTEM INTO PACKAGES

◼ Different owners - who is responsible for working on which diagrams?


◼ Different applications - each problem has its own obvious partitions;
◼ Clusters of classes with strong cohesion - e.g., course, course description, instructor,
student,...Or: use an architectural pattern to help find a suitable decomposition such as
MVC Framework
HOW TO CREATE A PACKAGE DIAGRAM

Example:
◼ Track Order Service for an online shopping store:
◼ Track Order Service is responsible for providing tracking information for the products
ordered by customers. Customer types in the tracking serial number, Track Order
Service refers the system and updates the current shipping status to the customer.
STEP-1: IDENTIFY THE PACKAGES PRESENT IN THE SYSTEM

◼ There is a "track order" service, it has to talk with other module to know about the
order details, let us call it "Order Processing".
◼ Next after fetching Order Details it has to know about shipping details, let us call that
as "Shipping".
◼ Finally if knows the status of the order it has to update the information to the user, let
us call this module as "UI Framework".
CONT…
STEP 2 - IDENTIFY THE DEPENDENCIES

(i). "Track order" package should get order details from "Order Processing" and on
the other hand, "Order Processing" also requires the tracking information from the
"Track Order" package, thus, the two modules are accessing each other which suffices
<<access>> dual dependency.
CONT…
CONT…

(ii). To know shipping information, "Shipping" requires to import "Track Order" to complete the shipping
process.
STEP 3 - FINALLY, TRACK ORDER DEPENDENCY TO UI FRAMEWORK IS
ALSO MAPPED IN TO THE DIAGRAM WHICH COMPLETES THE PACKAGE
DIAGRAM FOR TRACK ORDER SUBSYSTEM.
PACKAGE DIAGRAM EXAMPLE MVC STRUCTURE

You might also like