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

Chapter 2

Uploaded by

trytonegotiate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Chapter 2

Uploaded by

trytonegotiate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 52

Chapter Two

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

 The main purpose of UML is to


 support communication about the analysis and
design of the system being developed
 support the movement from the problem domain in
the "world" to the solution domain in the machine

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

• The UML has the following features:


– It is a generalized modeling language.
– It is distinct from other programming languages like C++,
Python, etc.
– It is interrelated to object-oriented analysis and design.
– It is used to visualize the workflow of the system.
– It is a pictorial language, used to generate powerful modeling
artifacts.
UML-Building Blocks
• Building blocks generate one complete UML
model diagram by rotating around several
different blocks.
• It plays an essential role in developing UML
diagrams. The basic UML building blocks are
enlisted below:
– Things
– Relationships
– Diagrams
Con’t…
Things:-
• Anything that is a real-world entity or object is termed as things. It can
be divided into several different categories:
– Structural things: Nouns that depicts the static behavior of a model is termed as
structural things. They display the physical and conceptual components. They
include class, object, interface, node, collaboration, component, and a use case.
– Behavioral things: They are the verbs that encompass the dynamic parts of a
model. It depicts the behavior of a system. They involve state machine, activity
diagram, interaction diagram.
– Grouping things: It is a method that together binds the elements of the UML
model. In UML, the package is the only thing, which is used for grouping.
– Annotational things: It is a mechanism that captures the remarks, descriptions,
and comments of UML model elements. In UML, a note is the only
Annotational thing
Con’t…

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

Professor teaches Course


* 1..*
teacher class

role names Multiplicity


defines the number of objects associated with an
instance of the association.
Default of 1;
Zero or more (*);
n..m; range from n to m inclusive
CS6359.0T1: Module
Notation and Multiplicity Adornments
 UML Association:
 a line between two concepts and a name
 they are bi-directional zero or more;
* T
"many"
 can have a multiplicity
 exist in class diagrams 1..*
T one or more

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..*

POST Captures Sale Paid-by Payment


1 1..* 1 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

 Example: A hospital and its wards. If the hospital is


18
destroyed, the wards also get destroyed.
3) Generalzation
• The generalization relationship implements the object-
oriented concept called inheritance or is-a relationship.
• It exists between two objects (things or entities), such
that one entity is a parent (superclass or base class),
and the other one is a child (subclass or derived class).
• A superclass has the most general attributes,
operations, and relationships that may be shared with
subclasses. A subclass may have more specialized
attributes and operations.
Con’t…
• For Example, a Bank Account is of two types - Savings
Account and Credit Card Account. Savings Account and Credit
Card Account inherit the common/ generalized properties like
Account Number, Account Balance, etc. from a Bank Account
and also have their specialized properties like unsettled
payment etc.
4) Realization

• In UML modeling, the realization is a


relationship between two objects, where the
client (one model element) implements the
responsibility specified by the supplier
(another model element).
• The realization relationship can be employed
in class diagrams and components diagrams.
Diagrams in the UML: Class Diagrams

 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…

• The class diagram is made up of three sections:


– Upper Section: The upper section encompasses the name of
the class. Some of the following rules that should be taken into
account while representing a class are given below:
• Capitalize the initial letter of the class name.
• Place the class name in the center of the upper section.
• A class name must be written in bold format.
• The name of the abstract class should be written
• in italics format.
Con’t…
• Middle Section: The middle section constitutes the attributes,
which describe the quality of the class. The attributes have the
following characteristics:
– The attributes are written along with its visibility factors, which are public
(+), private (-), protected (#), and package (~).
– The accessibility of an attribute class is illustrated by the visibility factors.
– A meaningful name should be assigned to the attribute, which will explain its
usage inside the class.
• Lower Section: The lower section contain methods or operations.
The methods are represented in the form of a list, where each
method is written in a single line. It demonstrates how a class
interacts with data.
Class Diagrams for Library Management System
Sequence Diagrams
 Interaction diagrams describe how groups of objects
collaborate in some behavior
 The UML defines several forms of interaction
diagram, the most common is the sequence diagram
 A class diagram shows a fixed view of a system
 A sequence diagram represents a dynamic view of a
system by capturing message sends over time.
 Can document a scenario such as
 Dealer deals cards to all players
 Withdraw Money when there is enough balance
 Withdraw Money when there is not enough balance
26
Notations of a Sequence Diagram
Sequence Diagram for Library Management
System
Sequence Diagrams
 Not good at showing details of algorithms such
as loops and conditional
 Good at showing the calls between participants
 Gives a good picture about which participants
are doing which processing

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…

• Notation of a State Machine Diagram:


Component diagram
• A component diagram is used to break down a
large object-oriented system into the smaller
components, so as to make them more
manageable.
• It models the physical view of a system such as
executables, files, libraries, etc. that resides
within the node.
• A component is a single unit of the system,
which is replaceable and executable.
Con’t…
• Notation of a Component Diagram:
a) A component

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!!

You might also like