Unit - 2 Introduction To UML
Unit - 2 Introduction To UML
Prepared By:
Prof. U. Verma
MPSTME Shirpur Campus
upendra.verma@nmims.edu
psg/1
What is UML?
Modeling involves
understanding ( semantics) a subject (system)
and
capturing and communicating this knowledge
The Unified Modeling Language ( UML) is:
A complete language for capturing knowledge (semantics) about a subject
(system) and communicating the knowledge (syntax)
the result of unifying the IT industrys best engineering practices
proposed by Booch, Rumbaugh and Jacobson-the Three Amigos
upendra.verma@nmims.edu
psg/2
..What is UML?
UML is the standard language for visualizing, specifying,
constructing, and documenting the artifacts of a software
intensive system
It can be used with all processes, throughout the development
life cycle, and across different implementation technologies
upendra.verma@nmims.edu
psg/3
..What is UML?
Visualizing UML is more than just a bunch of graphical
symbols. For each symbol in the UML notation is a well defined
semantics.
Specifying Building models that are precise, unambiguous,
and complete.
Constructing models can be directly connected to a variety of
programming language. It is possible to map model in the UML
to a programming language like JAVA, C++, or VB.
Documenting UML addresses the documentation of a
systems architecture and all of its details, provides language for
expressing requirements, for test, for modeling the activities of
project planning and release management.
upendra.verma@nmims.edu
psg/4
upendra.verma@nmims.edu
psg/5
Standardization
More companies joined the UML partners consortium to
contribute their ideas and produce version 1.1 of the UML with
Increased formalism
Improved structural packaging
Improved mapping of notation to semantics
UML 1.1 is accepted by OMG as a standard in fall 1997.
upendra.verma@nmims.edu
psg/6
upendra.verma@nmims.edu
psg/7
The UML enables and promotes a use-case-driven, architecturecentric, iterative, and incremental process that is object oriented
and component based.
upendra.verma@nmims.edu
psg/8
upendra.verma@nmims.edu
psg/9
upendra.verma@nmims.edu
psg/10
upendra.verma@nmims.edu
psg/11
upendra.verma@nmims.edu
psg/12
upendra.verma@nmims.edu
psg/13
Things
The abstractions that are first-class citizens in a model.
There are four kinds of things in the UML
1.
2.
3.
4.
Structural
Behavioral
Grouping
Annotational
upendra.verma@nmims.edu
psg/14
Structural
These are nouns of UML models which are static parts
represent elements that are either conceptual or physical.
There are seven kinds of structural things in the UML
1.
2.
3.
4.
5.
6.
7.
class
interface
collaboration
Use case
Active class
Component
node
upendra.verma@nmims.edu
psg/15
Class
Description of as set of objects that share same attributes,
operations, relationships, and semantics.
Graphically, a class is rendered as a rectangle.
interface
A collection of operation that specify a service of a class or
component.
Describes externally visible behavior of a class or
component or only a part of that behavior.
Defines set of operation specifications
Graphically, an interface is rendered as a circle.
upendra.verma@nmims.edu
psg/16
Collaboration
Defines an interaction and is a society of classes, interfaces
and other elements work together to provide some
cooperative behavior.
A given class might participate in several collaborations
Represents the implementation of patterns that make up a
system
Graphically, a collaboration is rendered as an ellipse with
dashed line, usually including only its name.
upendra.verma@nmims.edu
psg/17
Use case
It is a description of set of sequence of actions that a
system performs that yields an observable result of value to
a particular actor.
It is used to structure the behavioral things in a model.
It is realized by a collaboration.
Graphically, a use case is rendered as an ellipse with solid
line, usually including only its name.
upendra.verma@nmims.edu
psg/18
Active Class
The objects of active class own one or more processes or
threads so initiate control activity.
Graphically, an active class is rendered as a rectangle with
heavy lines.
Component
It is a physical and replaceable part of a system that
conforms to and provides the realization of a set of
interface.
Graphically, a component is rendered as a rectangle with
tabs, usually including only its name.
upendra.verma@nmims.edu
psg/19
Node
It is a physical element that exists at run time.
It represents a computational resource.
It has some memory and often processing capabilities.
Graphically, a node is rendered as a cube, usually including
only its name.
upendra.verma@nmims.edu
psg/20
Behavioral
These are dynamic parts of UML model.
These are verbs of a model.
Represents behavior over time and space.
There are two primary kinds of behavioral things
1. Interaction
2. State machine
upendra.verma@nmims.edu
psg/21
Interaction
It comprises a set of messages exchanged among set of
objects within a particular context to accomplish a specific
purpose.
It includes messages, action sequences, and links.
Graphically, a message is rendered as a directed line,
usually including name of its operation.
upendra.verma@nmims.edu
psg/22
State Machine
It is a behavior that specifies the sequence of state an
object or an interaction goes through during its lifetime in
response to events, together with its responses to those
events.
It includes events and activities.
Graphically, a state is rendered as a rounded rectangle,
usually including its name and its substates.
upendra.verma@nmims.edu
psg/23
Grouping
These are the organizational parts of UML model.
There is one primary kind of grouping thing, namely,
packages.
Package
It is a general purpose mechanism for organizing element
into groups.
Structural, behavioral and grouping things may be placed in
a package.
Graphically, a package is rendered as a tabbed folder,
usually including only its name and sometimes its contents.
upendra.verma@nmims.edu
psg/24
Annotational
These are the explanatory parts of UML model.
These are the comments.
There is one primary kind of annotational thing, called a
note.
Note
Its a symbol for rendering constraints and comments
attached to an element or a collection of elements.
Graphically, a note is rendered as a rectangle with a dogeared corner, together with a textual or graphical comment.
upendra.verma@nmims.edu
psg/25
Relationships
It tie things together.
There are four kinds of relationships in the UML.
1.
2.
3.
4.
Dependency
Association
Generalization
realization
upendra.verma@nmims.edu
psg/26
Dependency
It is a semantic relationship between two things in which a
change to one thing may affect the semantics of the other
things.
Graphically, a dependency is rendered as a dashed line,
possibly directed, and occasionally including a label.
upendra.verma@nmims.edu
psg/27
Association
It is a structural relationship that describes a set of links, a
link being a connection among objects.
Aggregation is a special kind of association representing a
structural relationship between a whole and its parts.
Graphically, an association is rendered as a solid line,
possibly directed, occasionally including a label, and often
containing multiplicity and role names.
upendra.verma@nmims.edu
psg/28
Association
1
Guides
Teacher
Student
Aggregation
1
Institute
Department
upendra.verma@nmims.edu
psg/29
upendra.verma@nmims.edu
psg/30
Relationships - contd..
An association class is an association that also has class properties(or a
class has association properties)
A constraint is a semantic relationship among model elements that
specifies conditions and propositions that must be maintained as true:
otherwise, the system described by the model is invalid
upendra.verma@nmims.edu
psg/31
Association
1
Guides
Teacher
Student
Guide
RS
Navigation
Aggregation
1
Institute
Department
upendra.verma@nmims.edu
psg/32
Association Vs Composition
1
Page
Frame
Window
Menu
Header
upendra.verma@nmims.edu
Slider
psg/33
Dependency
uses
Window
Button
access
Employee
Salary
upendra.verma@nmims.edu
psg/34
Association Classes
1
Teaches
Teacher
Course
Offering
No of students
Venue
Slot number
1
employs
Company
*
Employee
Job
Designation
Salary
upendra.verma@nmims.edu
psg/35
Realization
<interface>
Iaccount
AccountImpl
Deposit()
withdraw()
upendra.verma@nmims.edu
psg/36
Generalization
It is a specialization/generalization relationship in which
objects of the specialized elements are substitutable for
objects of the generalized element.
The child share the structure and the behavior of the parent.
Graphically, a generalization is rendered as a solid line with
a hollow arrowhead pointing to the parent.
upendra.verma@nmims.edu
psg/37
Generalization/Specialization
Superclass, Subclass, or Inheritance comes into picture in
generalization/Specialization.
upendra.verma@nmims.edu
psg/38
Generalization/Specialization..Continued
psg/39
Realization
It is a semantic relationship between classifier, wherein one
classifier specifies a contract that another classifier
guarantees to carry out.
Realization encounter in two places
upendra.verma@nmims.edu
psg/40
Realization
<interface>
Iaccount
AccountImpl
Deposit()
withdraw()
upendra.verma@nmims.edu
psg/41
Diagrams
It is the graphical presentation of a set of elements, most
often rendered as a connected graph of vertices (things)
and arcs (relationships).
UML includes nine different diagrams.
upendra.verma@nmims.edu
psg/42
UML Diagrams
upendra.verma@nmims.edu
psg/43
Behavioral View
Sequence
Collaboration
State Chart
Activity
Implementation View
Component
User view
User
View
* Use
case
Use
Case
Environment View
Deployment
upendra.verma@nmims.edu
psg/44
upendra.verma@nmims.edu
psg/45
upendra.verma@nmims.edu
psg/46
<<Uses>>
<<Extends>>
upendra.verma@nmims.edu
psg/47
upendra.verma@nmims.edu
psg/48
upendra.verma@nmims.edu
49
Interaction Diagram
Interaction diagrams describe how use cases are
realized as interactions among objects
Show classes, objects, actors and messages
between them to achieve the functionality of a
UseCase
Two types of interaction diagrams
Sequence diagrams
Collaboration diagrams
upendra.verma@nmims.edu
psg/50
..Sequence Diagram
Is used to elaborate a use case
Describes a scenario - it is normal that a use
case has multiple scenarios
Helps to describe the expected system
behavior to a user
Follows an event from inception to
completion of processing by the system
upendra.verma@nmims.edu
psg/51
Focus of Control
Return message
Termination
lifeline
upendra.verma@nmims.edu
psg/52
Sequence Diagram
Library
member
UI
Member
upendra.verma@nmims.edu
Book
Copy
psg/53
..Collaboration Diagram
describes interactions among Classes (
objects)
can be drawn instead of a sequence diagram
Message sequencing is shown using
sequence numbers
upendra.verma@nmims.edu
psg/54
Messages with
sequence
numbers
( Collaborates
with Class)
Actor
upendra.verma@nmims.edu
psg/55
Collaboration Diagram
upendra.verma@nmims.edu
psg/56
..Class Diagram
Shows the static structure of the system classes and their relationships
Classes
structure (attributes)
behavior (operations)
Relationships
Association, aggregation, dependency, and
inheritance
Multiplicity and navigation indicators
names
upendra.verma@nmims.edu
psg/57
2 Nary Association
4
3 Class
4 Binary Association
5 Constraint
6 Realizes Interface
7 Interface
upendra.verma@nmims.edu
psg/58
Class Diagram
Accountant
1
Book
no
hasBooks
1
Library
1
Visibility
Attribute
Title
Author
Publisher
Subject
Key words
edition
Price
orders
InitVal
* Ty peScope
a
a
a
a
a
a
a
hasLibrarian
OrderInf o
hasCopies
hasMembers
Visibility
Attribute
supplierId
NoOfCopies
*
1
CopyInLib
Librarian
Visibility
Attribute
isRef erence
accessionNo
isIssued
copyNo
Ty peScope
InitVal
a
a
a
a
0..5
Library Member
0..200
Visibility
Attribute
name
memberId
borrows
Ty peScope
InitVal
a
a
upendra.verma@nmims.edu
psg/59
Relationships
An association is a bi-directional connection between classes
An association is shown as a line connecting the related classes
An aggregation is a stronger form of relationship where the relationship is
between a whole and its parts
An aggregation is shown as a line connecting the related classes with a
diamond next to the class representing the whole
A dependency relationship is a weaker form of relationship showing a
relationship between a client and a supplier where the client does not have
semantic knowledge of the supplier
A dependency is shown as a dashed line pointing from the client to the
supplier
upendra.verma@nmims.edu
psg/60
Relationships - contd..
upendra.verma@nmims.edu
psg/61
Association
1
Guides
Teacher
Student
Guide
RS
Navigation
Aggregation
1
Institute
Department
upendra.verma@nmims.edu
psg/62
Association Vs Composition
1
Page
Frame
Window
Menu
Header
upendra.verma@nmims.edu
Slider
psg/63
Dependency
uses
Window
Button
access
Employee
Salary
upendra.verma@nmims.edu
psg/64
Association Classes
1
Teaches
Teacher
Course
Offering
No of students
Venue
Slot number
1
employs
Company
*
Employee
Job
Designation
Salary
upendra.verma@nmims.edu
psg/65
Realization
<interface>
Iaccount
AccountImpl
Deposit()
withdraw()
upendra.verma@nmims.edu
psg/66
Qualifier
Bank
Factory
Account #
Item #
Customer
Itemproduced
upendra.verma@nmims.edu
psg/67
psg/68
upendra.verma@nmims.edu
psg/69
upendra.verma@nmims.edu
psg/70
..Activity Diagram
Activity diagrams are similar to State Chart
diagrams.
However they describe the behavior of a Class in
response to internal processing.
upendra.verma@nmims.edu
psg/71
upendra.verma@nmims.edu
psg/72
Activity Diagram
upendra.verma@nmims.edu
psg/73
..Component Diagram
Describe organization and dependency
between the software implementation
components
upendra.verma@nmims.edu
psg/74
Dependency
upendra.verma@nmims.edu
psg/75
Component Diagram
upendra.verma@nmims.edu
psg/76
..Deployment Diagram
Describe the configuration of processing
resource elements and the mapping of
software implementation components onto
them
contain components - e.g. object code, source
code, and nodes - e.g. printer, database, client
machine
upendra.verma@nmims.edu
psg/77
Dependency
Node
Connector
upendra.verma@nmims.edu
psg/78
Deployment Diagram
LibServ er
LibMgmtSys
tcp-ip
tcp-ip
LibClient2
LibClient1
ClientLibrarian
ClientMember
upendra.verma@nmims.edu
psg/79
Package Diagram
A Package is :
an application view
upendra.verma@nmims.edu
psg/80
Dependency
Generalization
upendra.verma@nmims.edu
psg/81
Package Diagram
upendra.verma@nmims.edu
psg/82
upendra.verma@nmims.edu
psg/83
Modeling Process
Break up the system into packages. Draw a
high level Package Diagram for the system.
Draw Use Case diagrams for each package
Analyze each use case in detail - identifying
variations, common use cases, scenarios of
interest
Draw a Sequence /Collaboration diagram
for each scenario
upendra.verma@nmims.edu
psg/84
.. Modeling Process
Draw a Class Diagram for each package
classes will be shared across the entire
application model
a class will be owned by a package - others
will use it
upendra.verma@nmims.edu
psg/85
..Modeling Process
Draw
State Chart Diagrams or Activity Diagrams for
classes that exhibit a significantly dynamic
behavior
Component Diagrams to elucidate the
intercomponent dependencies
Deployment Diagrams to describe the
configuration of resource elements and mapping of
the software implementation components onto
them
upendra.verma@nmims.edu
psg/86