Chapter 2
Chapter 2
UML
The Unified Modeling Language (UML)
The UML stands for Unified modeling language, is a
standardized general-purpose visual modeling
language in the field of Software Engineering.
This is primarily a graphical communication
mechanism for developers and customers.
It is used for specifying, visualizing, constructing, and
documenting the primary artifacts of the software
system.
2
UML
3
UML is a Modeling Language
UML
graphical notation to describe software design
has rules on how to draw models of
classes
associations between classes
message sends between objects
like a blueprint to show what is going on during
analysis, design and implementation
Some Projects require UML documentation
4
Characteristics of UML
Relationships:-
•It illustrates the meaningful connections between
things. It shows the association between the entities and
defines the functionality of an application. There are
four types of relationships given below:
– Dependency
– Association
– Generalization
– Realization
Con’t…
Diagrams:-
•The diagrams are the graphical implementation of the models
that incorporate symbols and text.
•UML diagrams are classified into three categories that are given
below:
– Structural Diagram:It represents the static view of a system by
portraying the structure of a system.
– Behavioral Diagram:It depicts the behavioral features of a system. It
deals with dynamic parts of the system.
– Interaction Diagram:It is a subset of behavioral diagrams. It depicts
the interaction between two objects and the data flow between them.
Con’t…
• The diagrams are hierarchically classified in the
following figure:
Relationships in the UML
• Relationships depict a connection between several
things, such as structural, behavioral, or grouping
things in the unified modeling language.
• It constitutes four types of relationships,
i.e., dependency, association, generalization, and realization.
1) Dependency: A Uses Relationship
Dependencies
occurs when one object depends on another
if you change one object's interface, you need to
change the dependent object
arrows point from dependent to needed objects
CardReader
Jukebox
CDCollection
SongSelector
12
2)Association: Structural Relationship
Association
Association is a structural relationship that represents how two entities
are linked or connected to each other within a system. It can form
several types of associations, such as one-to-one, one-to-many, many-
to-one, and many-to-many.
Associations can be labeled getAccountWithID for example
BTW: The box with association is an official UML comment, must have that fold
association
getAccountWithID
Jukebox JukeboxAccountCollection
1 1
13
Associations (UML)
direction indicator:
how to read relation name
relationship name
1..52
T one to fifty two
5
Multiplicity T exactly five
adornments
15
Association
Names • Read these Type-VerbPhrase-Type
• POST is a Point of Sale Terminal)
Store • Not shown here: Attributes and Methods
1
• This just shows associations between objects
Contains
1..*
Airline
1
Employs
1..*
Assigned-to Assigned-to
Person Flight Plane
1 * * 1
1 *
16
Supervises
Aggregation: A Special Association
Aggregation: whole/part relationships
An association that models HAS-A relationships
The objects can exist independently of each other
It forms a weak association.
Place an open diamond on the whole.
School contains a collection of Student objects.
School Student
1..* *
Example: A doctor has patients when the doctor gets transfer
to another hospital, the patients do not accompany to a new
workplace. 17
Composition: A Special Association
Composition: Stronger relationship
One can not exist without the other
If the school folds, students live on
but the departments go away with the school
If a department closes, the school can go on AIC*
e.g.
School Department
1 1..*
1..*
*
Student
A class diagram
expresses class definitions to be implemented
lists name, attributes, and methods for each class
shows relationships between classes
UML allows different levels of detail on both
the attributes and the methods of one class
could be just the class name in a rectangle
or like the general form shown on the next slide
22
Con’t…
33
Syntax
Objects are lined up on top in rectangles
Object names :CardReader
Dashed lines represent lifetime of objects
Rectangles are activation lines
When the object is "alive"
Activation bar of the receivers of the message is
smaller than the sender's activation bar
Not much detail written
34
Another Example
http://www.ifi.uio.no/in219/verktoy/doc/html/doc/user/mg/dgmsuml6.html
Scenario: The user tries to use an ATM, but the account is not known
35
Scenario: The user
successfully withdraws
money from an ATM
36
Use Case Diagram
• A use case diagram is used to represent the dynamic
behavior of a system.
• It encapsulates the system's functionality by
incorporating use cases, actors, and their relationships.
• It models the tasks, services, and functions required by a
system/subsystem of an application. It depicts the high-
level functionality of a system and also tells how the
user handles a system.
State chart diagrams
• 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, a package, and a complete
system.
• State chart diagram describes the flow of control from one
state to another state. States are defined as a condition in
which an object exists and it changes when some event is
triggered.
• The most important purpose of State chart diagram is to model
lifetime of an object from creation to termination.
Con’t…
b) A node
Deployment Diagram
• The deployment diagram visualizes the physical
hardware on which the software will be deployed.
• It portrays the static deployment view of a system. It
involves the nodes and their relationships.
• The main purpose of the deployment diagram is to
represent how software is installed on the hardware
component.
• It depicts in what manner a software interacts with
hardware to perform its execution.
Con’t…
• Symbol and notation of Deployment diagram:
End!!