Chapter 8
Chapter 8
Overview of UML
UML(Unified Modeling Language) is a notation that
resulted from the unification of OMT (Object Modeling
Technique) and OOSE (Object-Oriented Software
Engineering
It is an industry-standard graphical language or modeling
language for specifying, visualizing, constructing, and
documenting the artifacts of software systems.
Goal: provide a standard notation that can be used by all
object-oriented methods
The UML uses mostly graphical notations to express the
OO analysis and design of software projects.
Simplifies the complex process of software design
Help acquire an overall view of a system.
Cont.…
Any real-world system is used by different users. The users can be
developers, testers, business people, analysts, and many more. Hence,
before designing a system, the architecture is made with different
perspectives in mind.
The most important part is to visualize the system from the
perspective of different viewers.
The better we understand the better we can build the system.
UML plays an important role in defining different perspectives of a
system. These perspectives are −
Design
Implementation
Process
Deployment
Cont..
Model a system:-
Describing the system at abstract level to comprehend its
complexity
Necessary to manage complexity
Good for quick understanding of the systems
Less chances of conflicting views between end-user and
system designers common understanding
In projects involving many participants, with different
technical and cultural backgrounds,
accuracy and clarity are critical standard notation
Cont...
System development focuses on three different models of
the system:
The functional model, use case diagrams, describes the
functionality of the system from the user’s point of view.
The object model, represented in UML with class
diagrams, describes the structure of the system in terms
of objects, attributes, associations, and operations.
The dynamic model represented in UML with
interaction diagrams, state machine diagrams, and
activity diagrams, describes the internal behavior of the
system.
Building blocks of the UML
The building blocks of UML can be defined as:
Things
Diagrams
Relationships
Things
It can be structural, behavioral, grouping or Annotational
Cont.…
Structural things:
The Structural things define the static part of the model.
They represent physical and conceptual elements.
Following are the brief descriptions of the structural things.
Class: represents set of objects having similar
responsibilities.
Interface: defines a set of operations which specify the
responsibility of a class.
Collaboration: defines interaction between elements.
Use case: represents a set of actions performed by a system
for a specific goal.
Component: a software unit.
Node: can be defined as a physical element that exists at run time
Cont.…
Behavioral things:
A behavioral thing consists of the dynamic parts of UML
models.
Following are the behavioral things:
cycle is important.
It defines the sequence of states an object goes through in
response to events.
Events are external factors responsible for state change.
Cont.…
Grouping things:
Grouping things can be defined as a mechanism to group
element.
Cont.…
Relationship
Relationship is another most important building block
of UML.
It shows how elements are associated with each other
and this association describes the functionality of an
application.
There are four kinds of relationships available.
Dependency: is a relationship between two things in
which change in one element also affects the other one.
Association: is basically a set of links that connects
elements of an UML model.
It also describes how many objects are taking part in that
relationship.
Cont.…
Generalization: can be defined as a relationship which
connects a specialized element with a generalized
element.
It basically describes inheritance relationship in the world of
objects.
Realization: it can be defined as a relationship in which two
elements are connected.
One element describes some responsibility which is not
implemented and the other one implements them.
This relationship exists in case of interfaces.
UML Diagrams
UML has two types of diagrams:
Structural Diagrams:
Behavioral Diagrams:
Structural Diagrams:
Visualize, specify, construct and document the static aspects of a
system.
There are following four structural UML diagrams.
Class Diagram
Object Diagram
Component Diagram
Deployment Diagram
Cont...
Behavioral Diagrams: visualize, specify, construct, and
document the dynamic aspects of a system.
Dynamic aspects of a system as representing its changing parts.
The dynamic aspects of a software system encompass things
such as the flow of messages over time and physical movements
of components across network
Following five are the UML behavioral diagrams.
Use Case Diagram
Sequence Diagram
Collaboration Diagram
State-chart Diagram
Activity Diagram
Use Case Diagram
Describe the functional behavior of the system as seen by
the user.
Model the functionality of a system using actors and use
cases.
Use cases are a set of actions, services, and functions that
the system needs to perform.
Mainly used for Visualizing/capturing the functional
requirements of a system that will translate into design
Used during requirements elicitation Specify how the
system interacts with actors.
Work like a contract between end user and software
developers.
Use Case Diagram Symbols and Notations:
Change
grade
Teacher
Generalization
Generalization: is a relationship between one general use case and a
special use case (used for defining special alternatives)
Represented by a line with a triangular arrow head toward the parent
use case.
<<extend>>
Bank’s Other’s
<<extend>>
<<extend>>
<<extend>>
Receipt Timeout
NoCash
Example
Invalid
<<extend>>
card
Transfer
ObjectName
Cont...
Lifeline
Lifeline represents the existence of an object over a
period of time.
It is represented by vertical dashed line.
Most objects that appeared in ‘Interaction diagram’ will
be in existence for the duration of an interaction.
So, these objects are aligned at top at top of diagram
with their lifeline from top to bottom of diagram.
ObjectName
Life Line
Cont...
Activation bar
It is also called as focus of control.
It shows the period of time during which an object is performing an
action.
It is represented by tall thin rectangle
Means the object is active and using resources during that time
period
Denotes when an object is sending or receiving messages
ObjectName
Activation bar
Cont...
Messages
The interaction in a sequence diagram between the objects can be
shown by using messages.
The messages on sequence diagram are specifies using an arrow
from participant that wants to pass the messages to the participant
that receive the messages .
Messages can be flow in whatever direction required for
interaction from left to right and right to left.
ObjectName ObjectName
[Message1]
[Message2]
Cont...
There are six main types of messages:
1. Synchronous messages:-
It is a message where the sender is blocked and waits until the
receiver has finished processing of message.
It is invoked the caller waits for the receiver to return from the
message invocation.
It is represented by solid line with full arrow.
Message
2. Asynchronous messages:-
It is a messages where the sender is not blocked and can continue
executing.
It is represent by solid line with half arrow.
Message
Cont...
3. Reflexive messages:-
If the object sends the message to itself then it is called as
Reflexive message.
It is represented by solid line with loops the lifeline of object.
Message
4. Return messages:-
It can be used at the end of activation bar to show that control flow
of activation returns to the participant that pass the original
message.
It is represent by dashed line from sender to receiver.
Message
Cont...
5. Create messages:-
It is used to create object during interaction(first message).
The object can be created by using <<create>> to indicate the
timing of creation. <<create>>
[Message]
6. Destroy messages:-
It is used to destroy the objects during interaction.
The objects can be terminated using <<destroy>> which points to
an “x”.
It indicates that object named message is terminated.
<<destroy>>
[Message]
Cont...
Time:-
The sequence diagram describes the order in which interaction
takes place.
So time in an important factor. The time on sequence diagram
starts at top of the page just below the object and then progress
down the page.
Time is all about ordering but not duration.
Actor:-
Shows entities that interact with or are external to the system.
Time
Cont...
ObjectName ObjectName
<<Message>>
<<Message>>
[Message]
Time Message
Message
Message
Message
Steps for constructing sequence diagram
Customer
1: Insert ATM
1.1: Validate
1.2: Validated
2: input pin
2.1: verify pin
Time Event:
This
refers to an event that stops the flow for a time.
Merge Event:
Synchronization:
It is represented as a straight, slightly
thicker line in an activity diagram.
A fork node is used to split a single
incoming flow into multiple concurrent
flows.
A join node joins multiple concurrent
flows back into a single outgoing flow.
A fork and join node used together are
often referred to as synchronization.
Insert Card Validate Card
Valid Invalid
Check Balance
Amount > Balance Amount<=Balance
The final state is denoted by a circle with a dot inside and may also
be labeled with a name.
Example: an ATM transaction
idle
Invalid
Insert card Validating card Cancel Eject
Take card
Card ok
Request Pin
Enter a pin
Wrong pin
Verifying
Pin ok
No balance
Account
Withdraw
Take cash & card
Debit
Component diagram
Component diagrams are used to model the physical aspects of a
system.
Now the question is, what are these physical aspects?
Physical aspects are the elements such as executables, libraries, files,
documents, etc. which reside in a node.
Component diagrams are used to visualize/describe the organization
and relationships of the components
It does not describe the functionality of the system but it describes the
components used to make those functionalities.
Cont..
Component diagrams are used during the implementation phase of an
application. However, it is prepared well in advance:
o To visualize the implementation details.
o To get an idea of the implementation.
This diagram is very important to implement the application
efficiently and for other aspects such as application performance,
maintenance, etc.
The implementation team of an application should have a proper
knowledge of the component details Component diagrams can be used
to −
o Model the components of a system.
system.
Create a visual for each of the components.
Employ
Station Account info
Bank
Data Base Card
Reader
Client
Desktop
ATM
Machine
ATM
Network
Client Desktop
transaction Customer Cash
Interface Dispenser
ATM transaction
Deployment Diagram
Deployment diagram Describes a static view of the run-time
configuration of hardware nodes and the software components
that run on those nodes.
The deployment diagram captures the configuration of the run time
element of the application.
Deployment diagrams show the hardware for your system, the
software that is installed on that hardware, and the middleware used
to connect the disparate machines to one another.
Deployment diagrams are used for describing the hardware
components, where software components are deployed.
Cont..
Component diagrams are used to describe the components and
deployment diagrams shows how they are deployed in hardware.
They are Closely related
Deployment diagrams can be visualized as the hardware
components/nodes on which the software components reside.
The purpose of deployment diagrams can be described as −
o Visualize the hardware topology of a system.
components.
o Describe the runtime processing nodes.
Cont..
An efficient deployment diagram is very important as it controls the
following parameters −
o Performance, Scalability, Maintainability, Portability
Card Receipt
reader Printer
Cash
dispenser
Display
ATM System
Node
Network
Interface
Server
Database internet
connection
application(system):
• Objects,
• Attributes, and
• Methods.
Class diagram is not only used for visualizing, describing,
Operations
Cont..
Visibility: Define the access specification of class
members(methods/attributes)
+ public
# protected
- private
~ package (default)
/ derived
Cont...
However, the UML provides abbreviations for visibility:
+ (public), - (private), and # (protected).
A public member is visible anywhere in the program and
may be called by any object within the system.(+)
A private member may be used only by the class that
defines it.(-) Rectangle
A protected member may be used only by -width:int
-heght:int
o (a) the class that defines it or /area:double
o (b) a subclass of that class.(#) +rectangle(widt
h:int,hegght:int)
:double
+distane(r.recta
ngle):double
Relationships between classes
Generalization: an inheritance relationship
Inheritance between classes
(dashed line, white arrow)
Interface implementation
(dashed line, white arrow)
Association: a usage relationship
Aggregation (clear white diamond)
Composition ( black diamond)
is a collection of methods. In an
implementation relationship.
a class implements an interface, and methods in the class