0% found this document useful (0 votes)
6 views

Comp 468 Lecture Slide Chapter 03 (Unified Modeling Language)

Uploaded by

donmitchell45
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Comp 468 Lecture Slide Chapter 03 (Unified Modeling Language)

Uploaded by

donmitchell45
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 103

Chapter Three

Unified Modeling Language (UML)

Prepared by: Marta G. (MSc.)


Contents

 Where can the UML be used


 Building blocks of the UML
 Relationships in the UML
 Diagrams in the UML
◦ Use case diagrams
◦ Class diagrams
◦ Sequence diagrams
◦ State chart diagrams
◦ Activity diagrams
◦ Component diagram
◦ Deployment diagram

◦ Diagram extensions
Unified Modelling Language
▪ UML is a standard language for modeling software systems.
▪ UML is a notation that resulted from the unification of OMT (Object
Modeling Technique) and OOSE (Object-Oriented Software
Engineering).
▪ Serves as a bridge between the requirements specification and the
implementation.
▪ Provides a means to specify and document the design of a software
system.
▪ It is process and programming language independent.
▪ It is a general-purpose language used to create visual designs for a
system
▪ Is particularly suited to object-oriented program development.
Cont…

 It is a general purpose modelling language. The main aim


of UML is to define a standard way to visualize the way a
system has been designed. It is quite similar to blueprints
used in other fields of engineering.
 UML is not a programming language, it is rather a
visual language.
Cont…
 When using UML the system development focuses on three
different models of the system.
 The functional model, represented in UML with 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 a system in terms of objects,
attributes, associations, and operations.
 The dynamic model, represented in UML with sequence
diagrams, state chart diagrams , and activity diagrams,
describes the internal behavior of the system.
Building blocks of the UML
 Things: the most important building blocks (such as
structural, behavioral, grouping and an notational) of
UML
◦ Anything that is a real world entity or object
 Relationships: articulates the meaning of the links
between things
◦ How the elements are associated with each other
 Diagrams: the ultimate output of the entire discussion
Building blocks of the UML cont….
Relationships
 Dependency: a change in one thing causes a change to the other
 Association: a structural relationship that describes the
connection between two things
 Specialization/Generalization: a relationship between the
superclass and the subclass
 Realization: one element describes some responsibility, which is
not implemented and the other one implements them
◦ Interface
Cont…
Diagrams
 The ultimate output of the entire discussion
◦ All the elements, relationships are used to make a
complete UML diagram and the diagram represents a
system
◦ Class, object, use case diagram
◦ Sequence, state chart diagram
◦ Activity, deployment diagram
Diagrams in the UML: Use case diagram
 Use cases are used during requirements elicitation and analysis
to represent the functionality of the system
 Use cases focus on the behavior of the system from an
external point of view
 A use case describes a function provided by the system that
yields a visible result for an actor
◦ An actor is a person, organization or any external system that
interact with the
system
◦ The actors are outside the boundary of the system while use cases
are inside the boundary of the system
Cont…

 Generally, use case is used for Functional Requirement


Analysis and Specification
 A use case is a step-by-step description of how a user will
use the system-to-be able to accomplish business goals
 Three key elements of use cases:
1. Environmental agents or actors that will cooperate with the
system
2. Use case diagram shows relations of the actors and use cases
3. Use case scenarios are plans for realization of user goals
or handling contingencies
Cont…
 Actors are represented with stick figures, use cases with an
ellipse inside the box, and the system is depicted as a box
 Use cases describes the functional requirements of the
system
◦ In terms of actors and use cases
 It defines a sequence of interactions between
◦ One or more actors and the system
 What the system do, not the internals of how it does
 A use case always starts with input from an actor
 The actor provides input to the system and the system
respond to the actor
Cont…
 Example: A simple watch system
 The WatchUser actor may either consult the time on their
watch (with the ReadTime use case) or set the time (with the
SetTime use case)
 However, only the WatchRepairPerson actor can change the
battery of the watch (with the ChangeBattery use case)
Types of actors
 Initiating actor (also called primary actor or simply
“user”): initiates the use case to achieve a goal

 Participating actor (also called secondary actor):


participates in the use case but does not initiate it. Subtypes
of participating actors:
◦ Supporting actor: helps the system-to-be to complete the use case
◦ Offstage actor: passively participates in the use case, i.e., neither
initiates nor helps complete the use case, but may be notified
about some aspect of it (e.g., for keeping records)
Tips for drawing a use-case diagram

1. A use case diagram should be as simple as possible.


2. A use case diagram should be complete.
3. A use case diagram should represent all interactions with the
use case.
4. If there are too many use cases or actors, then only the
essential use cases should be represented.
5. A use case diagram should describe at least a single module
of a system.
6. If the use case diagram is large, then it should be generalized.
Case study: An accident management system
 In an accident management system, field officers, such as a
police officer or a firefighter
◦ Have access to a wireless computer that enables them to interact
with a dispatcher
◦ Responsible for reporting emergencies
 The dispatcher in turn can visualize the current status of
all its resources, such as police cars or trucks, on a
computer screen and
◦ Dispatch a resource by issuing commands from a workstation
◦ Responsible for allocating resources and opening incidents
Cont….
Diagrams in the UML: Use case diagram cont…
Use case description
 To describe a use case, we use a template composed of six fields
from
 The name of the use case: is unique across the system so that
developers(and project participants) can unambiguously refer to
the use case
1. Participating actors: are actors interacting with the use case
2. Entry conditions: describe the conditions that need to be
satisfied before the use case is initiated
Cont…

4. The flow of events: describes the sequence of


interactions of the use case, which are to be numbered for
reference
 Flow of events are organized in two columns:
◦ The left column representing steps accomplished by the actor
◦ The right column representing steps accomplished by the system
5. Exit conditions: describe the conditions that are satisfied
after the completion of the use case
Cont…
6. Quality requirements: are requirements that are not
related to the functionality of the system
◦ These include constraints on the performance of the system, its
implementation, the hardware platforms it runs on, and so on
Cont…
Diagrams in the UML: Use case diagram

Relationships in use case diagram


 Association relationship: used to show communication of
actors and use cases when information is exchanged between
them
◦ It is depicted by a solid line between the actor and use case
◦ It can be used to denote access to functionality
 Include relationship: used to reduce redundancy in a complex
system by identifying commonalities in different use cases
Example: Assume that the Dispatcher can press at any time a
key to access a street map
Cont…
 It can be modeled by a use case ViewMap that is included
by the use cases OpenIncident and AllocateResources
 Example
Cont…
 The resulting model only describes the ViewMap functionality
once, thus reducing complexity of the overall use case model
 The include relationship can also be used to structure a
lengthy usecase
◦ The base: high level sequence, the inclusion low-level
sequence
 Two use cases are related by an include relationship if one of
them includes the second one in its flow of events
 In UML, include relationships are depicted by a dashed open
arrow originating from the including use case
Cont…

 Extend relationship: is used to model alternative paths that a


use case might take
◦ To show a conditional part of the base use case that is executed only
under certain circumstances
◦ To model complex or alternative paths
◦ It is also used for reducing complexity in the use case model
 The extension use case, depends on the base use case and
executes only if the condition in the base use case is true
 It can also be used in the specification of exceptional
behavior
Cont…

 Example: assume that the network connection between the


Dispatcher and the FieldOfficer can be interrupted at
anytime
Cont…

 The use case ConnectionDown describes the set of events


taken by the system and the actors while the connection is lost

 In general, exception cases, such as help, errors, and other


unexpected conditions, are modeled with extend relationships
 Use cases that describe behavior commonly shared by a
limited set of use cases are modeled with include relationships
Cont…
 Generalization relationships: is a third mechanism for reducing
the complexity of a model
 Generalization of Actors: one actor can inherit the role of the other
actor
◦ The descendant inherits all the use cases of the ancestor
◦ The descendant has one or more use cases that are specific to
that role
Example Use case: Wash Hands
 How a beginner writes the use case
Cont..
 How an experienced developer writes the use case:
Example of ATM Usecase
Example of ATM Usecase
Diagrams in the UML: Class diagram
 Class diagrams are used to describe the structure of the
system
◦ In terms of objects, classes, attributes, operations, and
their associations
 A class is a collection of objects that share a set of
attributes that distinguish the objects as members of the
collection
 Objects are entities that encapsulate state and behavior
◦ Each object has an identity: it can be referred
individually and is distinguishable from other objects
Cont…
 In UML, classes and objects are depicted by boxes
composed of three compartments
◦ The top compartment for name of the class or object
◦ The middle compartment for attributes
◦ The bottom compartment for operations or methods
 Object names are underlined to indicate that they are
instances
Examples
Visibility of Class attributes and Operations
 In object-oriented design, there is a notation of visibility
for attributes and operations. UML identifies four types of
visibility: public, protected, private, and package.
• + denotes public attributes or operations
• - denotes private attributes or operations
• # denotes protected attributes or operations
Cont…
• Public − A public member is visible from anywhere in the
system. In class diagram, it is prefixed by the symbol ‘+’.
• Private − A private member is visible only from within the
class. It cannot be accessed from outside the class. A private
member is prefixed by the symbol ‘−’.
• Protected − A protected member is visible from within the
class and from the subclasses inherited from this class, but
not from outside. It is prefixed by the symbol ‘#’.
Cont…
Example1: A UML class diagram for ReportEmergency
use case where detailed information is omitted until object
design
Cont…

 Example2: A UML object diagram


Diagrams in the UML: Class diagram cont…

Relationships in class diagram


 Association: defines a relationship between two or more
classes, denoting a static, structural r/p between classes
 One object is aware of the existence of another object
 The simplest (weakest) form of relation between classes
 It can be symmetrical (bidirectional) where navigation is
supported in both direction or asymmetrical
(unidirectional) where navigation is supported in only one
direction
Cont…
 Associations have the following properties:
◦ A name to describe the association between the two classes
◦ A role at each end, identifying the function of each class with
respect to the associations
◦ A multiplicity at each end, identifying the possible number of
instances
Cont…

 Most of the associations we encounter belong to one


of the following three types:
◦ A one-to-one association has a multiplicity 1 on each end
◦ A one-to-many association has a multiplicity 1 on one end
and 0..n (also represented by a star) or 1..n on the other
◦ A many-to-many association has a multiplicity 0..n or 1..n
on both ends
Cont…
Cont…
Aggregation: A restrictive form of
relation
 ”is part-of" association
 Objects are assembled to create a more
complex object
 The aggregate object coordinates its part
 It is a stronger relationship than an
association
◦ In aggregation, parts can be added or
removed from the aggregate whole
◦ symbolized by a clear white diamond
Cont…
Cont…
 Composition: is a stronger relationship than
an aggregation
◦ "is entirely made of"
◦ Parts cannot be added and removed from the
whole
◦ The part objects are created, live, and die
together with the whole
◦ The part object can belong to only one whole
◦ Parts cannot exist on their own
◦ Depicted by a black diamond
 There is a create-delete dependency of the
parts to the whole
Cont…
Cont…

Dependency: "uses temporarily"


• Exists between two classes if the changes to the definition
of one may cause changes to the other (but not the other
way around).
• Class1 depends on Class2
• A dashed line with an open arrow
Cont…
Inheritance/ Generalization
 Is the relationship between a general class and one or more
specialized classes
◦ Enables us to describe all the attributes and operations that are
common to a set of classes
◦ It is an “is-a" relationship between the subclass and the superclass
 Some classes are similar but not identical
◦ Have some attributes in common and others that are different
◦ Common attributes are abstracted into a generalized class, which is
referred to as a superclass
◦ The different attributes are properties of the specialized class, which is
referred to as a subclass
Cont…
Example
Example
Example
Scenario and Usecase with example
Usecase: “User Places an Order.”
Refining use case into scenarios
• Scenario 1: Successful Order Placement:
• The user adds items to the cart, proceeds to checkout, provides shipping
details, and confirms the order.
• Scenario 2: Order with Discount Code:
• A variant where the user applies a discount code during checkout,
impacting the final order total.
• Scenario 3: Order with Out-of-Stock Items:
• Addressing the scenario where an item in the cart is out of stock,
requiring user notification and decision-making.
Each scenario is then translated into a sequence diagram,
providing a visual representation of the interactions between
different components of the system during the execution of the
use case.
Diagrams in the UML: Sequence diagram

 Sequence diagrams are used to formalize the dynamic


behavior of the system and to visualize the communication
among objects
◦ Useful for identifying additional objects that participate in use
cases
 Sequence diagram shows object interactions arranged in
time sequence
◦ Can also depict loops and iterations
Cont…

 Numbering the messages on sequence diagram is not


essential, it can be shown from the top to the bottom
◦ Messages represent the information passed between
objects
 A sequence diagram ties use cases with objects
 It shows how the behavior of a use case (or scenario) is
distributed among its participating objects
Cont…

 The left-most column represents the actor who initiates


the use case
 Labeled arrows represent stimuli that an actor or an
object sends to other objects
Cont…
 One of the main reasons for constructing a sequence diagram is
◦ To uncover the responsibilities of the classes in the class
diagrams and to discover even new classes
◦ This helps the developer in deciding which objects require
particular methods
 Sequence diagrams are usually constructed after the initial class
diagram has been defined
 This process often also leads to refinements in the use case
◦ Correcting ambiguous descriptions
◦ Adding missing behavior
◦ Discovery of more objects and services
Cont…
Sequence Diagram Notations
Life line notation
 A sequence diagram is made up of several
of these lifeline notations that should be
arranged horizontally across the top of the
diagram.
 No two lifeline notations should overlap
each other.
 They represent the different objects or
parts that interact with each other in the
system during the sequence.
Cont…

 A lifeline notation with an actor element


symbol is used when the particular
sequence diagram is owned by a use case.
Cont..

 A lifeline with an entity element


represents system data.
 For example, in a customer service
application, the Customer entity
would manage all data related to a
customer.
Cont…
 A lifeline with a boundary
element indicates a system
boundary/ software element in a
system;
 For example, user interface
screens, database gateways or
menus that users interact with, are
boundaries.
Cont..

 And a lifeline with a control


element indicates a controlling entity
or manager.
 It organizes and schedules the
interactions between the boundaries
and entities and serves as the
mediator between them.
Cont…
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.
 In a sequence diagram, an interaction between two objects occurs when one
object sends a message to another.
Message arrows
Synchronous message
 synchronous message is used when the sender waits for
the receiver to process the message and return before
carrying on with another message.

Asynchronous message
 when the message caller does not wait for the receiver to
process the message and return before sending other
messages to other objects within the system.
Cont..
Return message
 It indicates that the
message receiver is done
processing the message
and is returning control
over to the message caller.
 Triggered by a
synchronous message
always implies a return
message.
Participant creation message

 Objects do not necessarily live for the entire duration of


the sequence of events. Objects or participants can be
created according to the message that is being sent.
Participant destruction message
 Participants when no
longer needed can
also be deleted from
a sequence diagram.
 This is done by
adding an ‘X’ at the
end of the lifeline of
the said participant.
Reflexive message
 When an object sends a message
to itself, it is called a reflexive
message.
 It is indicated with a message
arrow that starts and ends at the
same lifeline as shown in the
example below.
Comment
 UML diagrams generally permit the annotation of
comments in all UML diagram types.
 The comment object is a rectangle with a folded-over
corner as shown below. The comment can be linked to the
related object with a dashed line.
Example
Cont…
Life time of objects
 creation: arrow with 'new'
written above it
◦ notice that an object created after
the start of the scenario appears
lower than the others

 deletion: an X at bottom of
object's lifeline
◦ Java doesn't explicitly delete
objects; they fall out of scope and
are garbage-collected
Example
Diagrams in the UML: State chart diagram
 It is a technique that you can use to describe how your
system behaves and responds.
 State chart diagrams describe the dynamic behavior of an
individual object as a number of states and transitions
between these states
◦ A state represent a particular set of values for an object
 Given a state, a transition represents a future state the
object can move to and the conditions associated with the
change of state
 A state is a condition satisfied by the attributes of an object
◦ A state can be computed from the values of several attributes
Cont…
How to draw?
▪ A state is depicted by a rounded
rectangle
▪ A transition is depicted by open
arrows connecting two states
▪ States are labeled with their name
▪ A small solid black circle
indicates the initial state
▪ A circle surrounding a small
solid black circle indicates a final
state
Cont….
Example: an Incident object in FRIEND can exist in
four states:
 Active: denotes a situation that requires a response (e.g., an
ongoing fire, a traffic accident)
 Inactive: denotes a situation that was handled, but for which
reports are yet to be written
 Closed: denotes a situation that has been handled and
documented
 Archived: is a closed incident whose documentation has been
moved to off-site storage
Cont….

 We can represent these four states with a single attribute in the


Incident class - a status attribute
State chart diagram for user verification example
Simple login state chart diagram example
Cont…
 Read about fork, self translation and join in state
diagram?
Diagrams in the UML: Activity diagram

 Activity diagram describes the behavior of a system in terms


of activities
◦ Activities represent the execution of a set of operations
 The completion of these operations triggers a transition to
another activity
 Example: A UML activity diagram for Incident
corresponding to the above statechart diagram
Cont…
 Activity diagrams are state chart diagrams whose states are
action states
◦ The outgoing transitions in a state chart representation are
triggered by the completion of an action associated with the state
◦ This is called an action state
 By convention, the name of a state denotes a condition,
whereas the name of an action state denotes an action
Cont…

 If there are alternative transitions based on a condition of


the state of an object or a set of objects, they require
decisions and are depicted by a diamond with one or
more incoming open arrows and two or more outgoing
arrows
◦ The outgoing arrows are labeled with the conditions that select
a branch in the control flow
◦ The set of all outgoing transitions from a decision represents the
set of all possible outcomes
Cont….

Example: a decision after the OpenIncident action


selects between three branches:
◦ If the incident is of high priority and if it is a fire, the
FireChief is notified
◦ If the Incident is of high priority and is not a fire, the
PoliceChief is notified
◦ If neither condition is satisfied, that is, if the Incident is of
low priority, no superior is notified and the resource
allocation proceeds
Cont….
Cont…
Modeling a word
processor example
Cont…
 Read more about fork node, join node, flow final symbol
(try to use in your project)
 The main difference between activity and sequence
diagrams is that activity diagrams focus on the flow of
activities, whereas sequence diagrams focus on how
objects interact with each other over time.
 State chart diagrams focus on the internal state of an
object or system and how it responds to external
events, while activity diagrams focus on the sequence
of activities involved in a process or workflow.
Diagrams in the UML: Deployment diagram
 It models the physical architecture of a system, and it shows
the relationships between the software and hardware
components in the system and the physical distribution of
the processing.
 Deployment diagram is used to depict the relationship
among run-time components and hardware nodes
◦ Components are self-contained entities that provide services to
other components or actors
 UML is mainly designed to focus on software artifacts of a
system
◦ But deployment diagrams focus on software components and
hardware components
Cont…

 Itis structural diagram that shows a set of nodes


and their relationships
◦ Nodes are represented by boxes containing component
icons
◦ Dependencies between components are represented by
dashed arrows
Cont…
Example: A Web server is a component that provides services
to Web browsers
◦ A Web browser, such as Safari or IE, is a component that provides
services to a user
◦ A distributed system can be composed of many interacting run-time
components
Component diagram
▪ Component diagrams are used in modelling the physical aspects
of object-oriented systems that are used for visualizing,
specifying, and documenting component-based systems and also
for constructing executable systems through forward and reverse
engineering.
▪ Component diagrams are essentially class diagrams that focus on
a system's components that often used to model the static
implementation view of a system.
Cont…
Read more about…

 Provided interface, required interface and port


Example
cmp componenet Diagram

Account
Admin

Announcement
Supervisor

Assessment

Acceptance
letter
Department
Head
Assessment security
form/letter

Notification
Student

Applicant
Database
Manager

Field

category
Thank you for your attention!

You might also like