SDA-Lect13-Fall2024-Package, Component, Activity and Deployment Diagrams
SDA-Lect13-Fall2024-Package, Component, Activity and Deployment Diagrams
CS-3004
Lecture# 12
2
Packages
java::util java
util
Date java::util::Date myPackage::Date
Date
3
Package
• Classes are basic structural units in an OO system
• In large systems with hundreds of classes, need to group the (related)
classes together into packages
• A package in UML can be a collection of any packageable UML elements
but it is most commonly a collection of classes
• A package may contain other packages (subpackages)
• A package in UML corresponds to a package in Java or a namespace in C+
+
• Each package is a namespace
– There must never be more than one class within a package with any given name
– Classes in different packages can have the same name
• If several teams working on project, each could work on a different package
– Would mean they don’t have to worry about name clashes
• To distinguish between classes with the same name in different packages,
use fully qualified name
– e.g., java::util::Date, myPackage::Date
• UML package icon is a tabbed folder
– Can show just name or contents too
• If just name shown, then can be written in the middle of the icon, otherwise name written on tab
– Can show all details of class or even class diagram within package
– At other extreme, can just list names of classes within the package icon
4
Use Case Package Diagram:
s
Q Q s r
r T
V
T u
10
Relationships between packages
p
p
r q
r q
C B
C B E
E s
s
A
A
foo: ??
foo: ?? D
D
presentation domain
12
Package import
• Element import identifies an element in another package and allows the
element to be referenced using its name without a qualifier.
• Element import indicated by dashed arrow with open arrowhead from
importing package to imported element and labelling arrow with
– Keyword <<import>>, if visibility of imported element within importing package is
public and
– Keyword <<access>>, if visibility of imported element within importing package is
private
a «import» C
a «import» C
«import» «import» G
«import» F «import» G
F
h F
h F
«access»
«access»
C
C D
D
In above example
•Class b::C is referred to as just C in package a, and has public visibility within
package a
•Imported class C hides outer class e::C which must be referred to by its fully
qualified name (before import, C referred to e::C in package a)
•Class b::F is imported into package a, but there is already a class called F in a,
therefore cannot import b::F without aliasing it
• Class b::F is referred to as G in package a
•Imported class b::D can be referred to as D in package a, and has private visibility
within package a
•Package h imports package a which means that, in h, b::C is referred to as C and
b::F is referred to as G
• b::D is not accessible from h because its visibility in a is private
14
Package import
auxiliary
auxiliary
«access»
«access»
«import»
«import»
shoppingCart webShop
shoppingCart webShop
«import»
«import»
types
types
• A package import is a directed relationship that identifies a package whose members are
to be imported by a namespace (package)
• Importing namespace adds names of members of imported package to its namespace
• Conceptually equivalent to having an element import to each individual member of the
imported namespace
• Notated using dashed line with open arrowhead from importing namespace to imported
package, labelled with keyword
– <<import>> if package import is public and
– <<access>> if package import is private
• If package import is public, then imported elements will be visible outside of importing
package, while if it is private, they will not be visible
• In example above, elements in types are imported to shoppingCart and then further
imported to webShop
• But elements of auxiliary only accessible from shoppingCart, not webShop
15
Components
• UML defines a component to be
– “a modular unit with well-defined interfaces that is replaceable within its environment”
(UML Superstructure Specification, v.2.0, Chapter 8)
• Component-based design emphasises reuse
– Component is an autonomous unit within a system
• Component defines its behaviour in terms of provided and required interfaces
– A component may be replaced with another if they both provide and require the same
interfaces
• In UML, a component is a special type of class
– However, a component will often be a collection of collaborating classes
• A component can therefore have attributes and operations and may participate in
associations and generalizations
• A component provides interfaces that it realizes and exposes to its environment
• A component may require interfaces from other components in its environment in
order to be able to provide all its functionality
• External or “Black box” view on a component considers its publicly visible properties
and operations
• Internal or “White box” view on a component considers its private properties and
realizing classifiers (i.e., the classes and other elements inside the component) and
shows how the behaviour of the component is realized internally
16
17
Component notation
18
Internal, white-box view on components
«interface» «interface»
OrderEntry Person
create() «use» findByName()
«component»
validateDetails() create()
Order
addOrderline() getDetails()
19
Artifacts
20
Component Diagram – another example
(www.cs.tut.fi/tapahtumat/olio2004/richardson.pdf)
21
Component Diagram – another example
(www.cs.tut.fi/tapahtumat/olio2004/richardson.pdf)
22
What is a Deployment Diagram?
• Deployment Diagram – a diagram that shows the physical relationships
among software and hardware components in a system
– Components – physical modules of code
– Connections – show communication paths
– Dependencies – show how components communicate with other
components
– Nodes – computational units, usually a pieces of hardware
23
• A deployment diagram is a UML diagram type that shows the
execution architecture of a system, including nodes such as
hardware or software execution environments, and the middleware
connecting them.
24
Purpose
• Component diagrams are used to describe the components and
deployment diagrams shows how they are deployed in hardware.
• Most of the UML diagrams are used to handle logical components but
deployment diagrams are made to focus on the hardware topology of a
system. Deployment diagrams are used by the system engineers.
25
• The purpose of deployment diagrams can be
described as −
– Visualize the hardware topology of a system.
– Describe the hardware components used to deploy
software components.
– Describe the runtime processing nodes.
26
27
The physical layer
«LAN»
davesPC : PC 54mbps wireless susannesMac: Mac
susannesMac: Mac
«artifact»
p1: PlayerInterface «LAN»
54mbps wireless
«artifact»
p2: PlayerInterface
«artifact»
oxo: GameEngine
J2EE Membership
Server Server
DecNet
Tomcat
Server
30
Structural Diagrams - Deployment Diagram
(http://www.agilemodeling.com/artifacts/deploymentDiagram.htm)
31
Activity Diagrams
• Fancy flowchart
– Displays the flow of activities involved in a single process
– States
• Describe what is being processed
• Indicated by boxes with rounded corners
– Swim lanes
• Indicates which object is responsible for what activity
– Branch
• Transition that branch
• Indicated by a diamond
– Fork
• Transition forking into parallel activities
• Indicated by solid bars
– Start and End
Sample Activity Diagram
• Ordering System
• May need multiple
diagrams from
other points of view
Activity Diagram Example