You are on page 1of 68

Software Architecture and

Design
UML Diagrams
UML Diagrams
• A UML diagram is a diagram based on the UML
(Unified Modeling Language) with the purpose of
visually representing a system along with its main
actors, roles, actions, artifacts or classes, in order to
better understand, alter, maintain, or document
information about the system.
What are the types of UML Diagrams?
Class Diagram
Class Diagram
• In software engineering, a class diagram in the Unified
Modeling Language (UML) is a type of static structure
diagram that describes the structure of a system by
showing the system's classes, their attributes,
operations (or methods), and the relationships
among objects.
Essential elements of class diagram

Class Name

Attributes

Operations
Relationships
There are mainly three kinds of relationships in UML:
• Dependencies
• Generalization
• In UML modeling, a generalization relationship is a relationship in which one
model element (the child) is based on another model element (the parent).
• Association
• Association is the most commonly used relationship between a class and a
class, which means that there is a connection between one type of object and
another type of object.
PEOPLE
- name
- address
+ ToString ()

PLAYER COACH
6 + levelOfAccredition
+ playerNo
+ position + experience
12
+ BelongsToTeam ()
+ CoachTheTeam ()

1
1

HOCKEY TEAM
1 *
+ teamName
+ teamRecord

1 + PlayGame ()

* 4 2 GAME
CAPTAIN
*
+ score
+ GuidestheTeam () + location

HOCKEY LEAGUE
1
+ LeagueName

+ ContainsTeam ()
Activity Diagram
Activity Diagram
• ACTIVITY DIAGRAM is basically a flowchart to represent the flow
from one activity to another activity. The activity can be described as
an operation of the system. The basic purpose of activity diagrams is
to capture the dynamic behavior of the system.. It is also called
object-oriented flowchart.
• This UML diagram focuses on the execution and flow of the behavior
of a system instead of implementation. Activity diagrams consist of
activities that are made up of actions that apply to behavioral
modeling technology.
Components(Notations) of Activity
Diagram
1. Initial State
2. Action or Activity State
3. Action Flow or Control flows
4. Decision node and Branching
5. Fork
6. Join
7. Merge or Merge Event
8. Swimlane
9. Final State or End State
Initial State
• Initial State – The starting state
before an activity takes place is
depicted using the initial state.
• We use a black filled circle to
depict the initial state of a
system.
Action or Activity State
• Action or Activity State – An
activity represents execution of
an action on objects or by
objects.
• We represent an activity using a
rectangle with rounded corners.
• Basically, any action or event
that takes place is represented
using an activity.
Action Flow or Control flows
• Action Flow or Control flows –
Action flows or Control flows are
also referred to as paths and
edges.
• They are used to show the
transition from one activity state
to another.
Decision node and Branching
• Decision node and Branching –
When we need to make a
decision before deciding the
flow of control, we use the
decision node.
Fork
• Fork – Fork nodes are used to
support concurrent activities.
• We use a rounded solid
rectangular bar to represent a
Fork notation with incoming
arrow from the parent activity
state and outgoing arrows
towards the newly created
activities.
Join
• Join – Join nodes are used to
support concurrent activities
converging into one.
• For join notations we have two
or more incoming edges and one
outgoing edge.
Merge or Merge Event
• Merge or Merge Event –
Scenarios arise when activities
which are not being executed
concurrently have to be merged.
Swimlane
• Swimlane – We use swimlane for
grouping related activities in one
column.
• It provides a way to organize and
categorize the different actors or
entities involved in a process.
• Swimlane can be vertical and
horizontal.
• Swimlane are used to add
modularity to the activity
diagram.
Final State or End State
• Final State or End State – The state
which the system reaches when a
particular process or activity ends is
known as a Final State or End State.
• We use a filled circle within a circle
notation to represent the final state in
a state machine diagram.
• A system or a process can have
multiple final states.
Commuter Ticket Vending Machine Bank

Request for Ticket Request Trip Info

Calculate
Payment due

Request
Payment
options

credit card Authorize


payment
cash Dispense Change if
any

Dispense Ticket to
Commuter

Display Thank You


Phase Message
hase

hase
Sequence Diagram
What is a Sequence Diagram?
• Sequence Diagrams – A sequence diagram simply depicts interaction
between objects in a sequential order i.e., the order in which these
interactions take place.
• Sequence diagrams describe how and in what order the objects in a
system function.
• A sequence diagram is the most commonly used interaction diagram.
Interaction diagram – An interaction diagram is used to show the
interactive behavior of a system.
Components of Sequence Diagram
1. Actors
2. Lifelines
3. Activation Bars
4. Messages
• Synchronous messages
• Asynchronous Messages
• Create Message
• Delete Message
• Self Message
• Reply Message
• Found Message
• Lost Message
5. Guards
6. Sequence Fragments
Actors
• An actor in a UML diagram
represents a type of role where
it interacts with the system and
its objects.
• It is important to note here
that an actor is always outside
the scope of the system.
Example… An actor interacting with a seat
reservation system.
Lifelines
• A lifeline is a named element
which depicts an individual
participant in a sequence
diagram.
• Lifeline elements are located at
the top in a sequence diagram.
• The standard in UML for naming
a lifeline follows the following
format:
Instance Name : Class Name
Example…
Activation Bars
• The activation bar is the
box placed on the lifeline.
• It is used to indicate that
an object is active (or
instantiated) during an
interaction between two
objects.
Messages
• Communication between
objects is depicted using
messages.
• The messages appear in
a sequential order on the
lifeline.
• We represent messages
using arrows.
Synchronous messages
• A synchronous message
waits for a reply before the
interaction can move
forward.
• The sender waits until the
receiver has completed the
processing of the message.
• We use a solid arrowhead to
represent a synchronous
message.
Asynchronous Messages
• Asynchronous Messages –
An asynchronous message
does not wait for a reply
from the receiver.
• We use a lined arrowhead to
represent an asynchronous
message.
Create message
• Create message – We use a
Create message to instantiate
a new object in the sequence
diagram.
• It is represented with a dotted
arrow and create word
labelled on it to specify that it
is the create Message symbol.
Delete Message
• Delete Message – We use a
Delete Message to delete an
object.
• When an object is deallocated
memory or is destroyed within
the system, we use the Delete
Message symbol.
• It is represented by an arrow
terminating with a x.
Self Message
• Self Message – Certain
scenarios might arise where
the object needs to send a
message to itself.
• Such messages are called Self
Messages and are
represented with a U-shaped
arrow
Example…
• Consider a scenario
where the device wants
to access its webcam.
• Such a scenario is
represented using a self
message.
Reply Message
• Reply Message – Reply
messages are used to show
the message being sent from
the receiver to the sender.
• We represent a return/reply
message using an open
arrowhead with a dotted line.
Found Message
• Found Message – A Found
message is used to
represent a scenario
where an unknown source
sends the message.
• It is represented using an
arrow directed towards a
lifeline from an end point.
Example…
• Found message can be
due to multiple reasons
and we are not certain
as to what caused the
hardware failure.
Lost Message
• Lost Message – A Lost
message is that is not
received or processed by the
intended recipient, and it is
typically depicted as a gap or
break in the communication
flow between lifelines.
• It is represented using an
arrow directed towards an
end point from a lifeline.
Guards
• Guards – To model conditions
we use guards in UML.
• Guards play an important role in
letting software developers
know the constraints attached to
a system or a particular process.
• For example: In order to be able
to withdraw cash, having a
balance greater than zero is a
condition that must be met.
Sequence Fragments
• Sequence fragments
makes it quite easy for the
creation and maintenance
of an accurate sequence
diagram.
• It is represented by a box
called a combined
fragment, encloses a part
of interaction inside a
sequence diagram.
Operator Fragment Type

alt Alternative multiple fragments: The only fragment for which the
condition is true, will execute.

opt Optional: If the supplied condition is true, only then the fragments will
execute. It is similar to alt with only one trace.

par Parallel: Parallel executes fragments.

loop Loop: Fragments are run multiple times, and the basis of interaction is
shown by the guard.
Bank
Customer ATM
Server

insert card

Prompt for PIN


Enters PIN Request for PIN validation

Processes Request
Display error message PIN Invalid

Display Transaction Menu PIN Valid

Input transaction Details Request to Debit the account

Processes Request

Display error message Insufficient Balance

Request Processed Successfully

Dispense Cash

Collect Cash Update Balance

Display Balance and ask for receipt

Request Reciept

X Print Reciept

X
X
State Machine Diagram
What is a State machine Diagram?
• The State machine diagram is also called the State chart or State
Transition diagram, which shows the order of states underwent by an
object within the system.
• It captures the software system's behavior.
• It models the behavior of a class, a subsystem, and a complete
system.
• It also defines several states of a component within the system.
• Each object/component has a specific state.
Notations/Components of State Machine
Diagram
• Following are the notations of a state machine diagram enlisted
below:
Initial State

• Initial state: It defines the


initial state (beginning) of a
system, and it is represented
by a black filled circle.
Final state

• Final state: It represents the


final state (end) of a system. It
is denoted by a filled circle
present within a circle.
Decision box

• Decision box: It is of diamond


shape that represents the
decisions to be made.
Transition
• Transition: A change of control
from one state to another due to
the occurrence of some event is
termed as a transition.
• It is represented by an arrow
labeled with an event due to
which the change has ensued.
Transition labels
• Events: An event is a trigger that
causes the change of state.
• Guards: When the event occurs,
the guard condition is first
checked. If it is true, the class
changes its state accordingly.
• Guard conditions are written in
square brackets.
State Box
• State box: It depicts the
conditions or circumstances
of a particular object of a
class at a specific point of
time.
• A rectangle with round
corners is used to represent
the state box.
Component Diagram
What is a Component Diagram?
• A component diagram breaks down the actual system under
development into various high levels of functionality.
• A component represents a modular part of a system.
• A component diagram is used to break down a large object-oriented
system into the smaller components, so as to make them more
manageable.
Basic Concepts of Component Diagram
• A component in UML can be modeled as:
1. A rectangle with the component's name
2. A rectangle with the component icon
3. A rectangle with the stereotype text and/or icon
Interfaces
• It represents the communication points between components.

• Provided Interface:
Represents the set of interfaces that a component provides to its environment.

• Required Interface:
Represents the set of interfaces that a component requires from its
environment.
Interfaces…
Port
• Ports are represented using a square along the edge of the system or
a component. A port is often used to help expose required and
provided interfaces of a component.
Example - Using Interface (Order System)
Deployment Diagram
What is a Deployment Diagram?
• Deployment Diagram is a type of diagram that specifies the physical
hardware on which the software system will execute.
• The deployment diagram maps the software architecture created in
design to the physical system architecture that executes it.
• Deployment diagrams are used with the sole purpose of describing
how software is deployed into the hardware system.
• It visualizes how software interacts with the hardware to execute the
complete functionality.
Basic Concepts of Deployment Diagram
• A deployment diagram consists of the following notations:
• A node
• A component
• An artifact
• An interface
Artifact
• You can use the artifact to
describe a framework which is
used during the software
development process or an
executable file.
• The most common artifacts are
as follows,
• Source files
• Executable files
• Database tables
• Scripts
• Libraries
Node
• Node is a computational
resource upon which artifacts
are deployed for execution.
• A node is a physical thing that
can execute one or more
artifacts.
Example – Deployment Diagram

You might also like