UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
CAED
UML (Use Case Diagram)
Lab Manual 16
Dated:
4 th
December, 2023 to 8th December, 2023
Semester:
FALL 2023
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
Lab Instructions
1. All Students should reach at lab on time.
2. Students should sit on the same computer during whole semester.
3. Student should make a directory by his/her name and store all his/her data in it.
4. Student could take the backup of his/her program the instructor permission.
5. Record Instructions: 1. Lab copy should be updated. 2. Lab copy should be checked on each lab.
Lab Objective:
Understand what is UML?, What are its goals?, Different types different UML diagrams and their usage.
How to add Notes and Constraints in UML?, Understand concepts of “Association” and “Relationship”
between classes, How to represent associations in UML?.
Understand concepts of “Relationship” between different classes and a class itself, Understand
“Generalization” in UML, How to represent these things in UML?.
Understand “Association classes, Links, Aggregation and Composition” in UML, How to represent
these things in UML?
Tools:
MS Visio, E-draw
UML:
UML is a standard language for specifying, visualizing, constructing, and documenting the artifacts
of software systems.
UML stands for Unified Modelling Language.
UML is different from the other common programming languages like C++, Java, COBOL
etc.
UML is a pictorial language used to make software blue prints.
So UML can be described as a general purpose visual modelling language to visualize, specify,
construct and document software system.
UML has a direct relation with object oriented analysis and design.
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
Goals of UML:
A picture is worth a thousand words, this absolutely fits while discussing about UML. There
are a number of goals for developing UML but the most important is to define some general
purpose modelling language which all modelers can use and also it needs to be made simple
to understand and use.
UML diagrams are not only made for developers but also for business users, common people
and anybody interested to understand the system. The system can be a software or non-
software. So it must be clear that UML is not a development method rather it accompanies
with processes to make a successful system.
At the conclusion the goal of UML can be defined as a simple modelling mechanism to
model all possible practical systems in today’s complex environment.
A Conceptual model of UML:
To understand conceptual model of UML first we need to clarify: What is a conceptual model? and
why a conceptual model is at all required?
A conceptual model can be defined as a model which is made of concepts and their
relationships. A conceptual model is the first step before drawing a UML diagram. It helps
to understand the entities in the real world and how they interact with each other.
As UML describes the real time systems it is very important to make a conceptual model and then
proceed gradually. Conceptual model of UML can be mastered by learning the following three
major elements:
UML building blocks
Rules to connect the building blocks
Common mechanisms of UML
Object Oriented concepts:
Objects concrete and otherwise, are all around us. They make up our world. First and foremost, an
object is an instance of a class (a category). You and I, for example, are instances of the Person
class. An object has structure. That is, it has attributes (properties) and behavior. An object's
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
behavior consists of the operations it carries out. Attributes and operations taken together are called
features. An object contains both data and methods that control the data. The data represents the
state of the object.
The objects are the real world entities that exist around us and the basic concepts like
abstraction, encapsulation, inheritance, polymorphism all can be represented using UML. So UML
is powerful enough to represent all the concepts exists in object oriented analysis and design. UML
diagrams are representation of object oriented concepts only. So before learning UML, it becomes
important to understand OO concepts in details.
Following are some fundamental concepts of object oriented world:
Class: Class is an entity, a template for making objects, a collection of things that share
some common features.
Object: Object represent an instance of a single entity/class.
Abstraction: It means, simply, to filter out an object's properties and operations until just the
ones you need are left.
Encapsulation: Encapsulation is the mechanism of hiding data from outside world.
Association: When classes are connected together conceptually.
Composition: When an object is composed of another object.
Inheritance: Inheritance is the mechanism of making new classes from existing one.
Polymorphism: It defines the mechanism to exist in different forms.
Interface: Implemented by multiple classes.
UML Diagrams:
There are two broad categories of diagrams and then are again divided into sub-categories:
1. Structural Diagrams
2. Behavioral Diagrams
The structural diagrams represent the static aspect of the system. These static aspects represent
those parts of a diagram which forms the main structure and therefore stable.
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
These static parts are represents by classes, interfaces, objects, components and nodes.
The four structural diagrams in UML are:
Class diagram
Object diagram
Component diagram
Deployment diagram
Behavioral diagrams basically capture the dynamic aspect of a system. Dynamic aspect can be
further described as the changing/moving parts of a system.
UML has the following five types of behavioral diagrams:
Use case diagram
Sequence diagram
Collaboration diagram
Activity diagram
UML Class Diagram
The class diagram is a static diagram. It represents the static view of an application. The class
diagram describes the attributes and operations of a class and also the constraints imposed on the
system.
Purpose:
The class diagrams are widely used in the modelling of object oriented systems because they are the
only UML diagrams which can be mapped directly with object oriented languages.
Why Use Cases: What they are?
In the previous labs, we have dealt with diagrams that provide a static view of the classes in
a system. The static view helps an analyst communicate with a client. The dynamic view helps an
analyst communicate with a team of developers, and helps the developers create programs. But
neither the static view nor the dynamic view shows the system's behavior from the user's point of
view. Understanding that point of view is key to building systems that are both useful and usable.
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
Modeling a system from a user's point of view is the job of the use case.
Consider an example: You recently bought a digital camera. When you were shopping for it, you
encountered a wide variety of possibilities. How did you decide which one to buy? You asked
yourself exactly what you wanted to do with a camera. Did you want extreme portability or did you
want a larger camera with a bigger lens? Would you be taking distance shots? Did you want to take
pictures and post them on the web? Did you primarily want to make prints? If so, how large? Did
you want to make short movies? With sound?
We all go through a process like this when we make a non-impulse purchase. What we're doing is a
form of use case analysis: We're asking ourselves how we're going to use the product or system.
The important thing is to know what those requirements are. The use case helps analysts work with
users to determine system usage. A collection of use cases depicts a system in terms of what users
intend to do with it.
Think of a use case as a collection of scenarios about system use. Each scenario describes a
sequence of events. Each sequence is initiated by a person, another system, a piece of hardware, or
by the passage of time. Entities that initiate sequences are called actors. The result of the sequence
has to be something of use either to the actor who initiated it or to another actor.
Use Case diagram:
Use case diagrams are usually referred to as behavioral diagrams and used to describe a set of
actions i.e. use cases that some system or systems i.e. subject should or can perform in
collaboration with one or more external users of the system i.e. actors. Each use case should
provide some observable and valuable result to the actors or other stakeholders of the system.
Use case diagram can be termed as a specialization of a class diagram, and class diagram is
a structure diagram.
Use case diagrams are in fact twofold - they are both behavior diagrams, because they describe
behavior of the system, and they are also structure diagrams- as a special case of class
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
diagrams where classifiers are restricted to be either actors or use cases related to each other
with associations.
It helps gather system requirements and information from user’s point of view.
A use-case diagram consists of:
Actor - Something with a behavior or role, e.g., a person, another system, organization.
Use case - A list of actions or event steps, typically defining the interactions between an
actor and a system, to achieve a goal. The actor can be a human, an external system, or time.
Elements of a Use case diagram:
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
Actor
• Actor is someone interacting with use case (system function). Named by noun.
• Similar to the concept of user, but a user can play different roles; (example: a prof. can be
instructor and researcher – plays 2 roles with two systems).
• Actor triggers use case.
• Actor has responsibility toward the system (inputs), and Actor have expectations from the system
(outputs).
Use Case
•System function (process – automated or manual).
•Named by verb.
•Each Actor must be linked to a use case, while some use cases may not be linked to actors.
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
Some other details:
Relationships among Use Cases
Use cases can relate to one another. One way, inclusion, enables you to reuse one use case's
steps inside another use case. The other way, extension, allows you to create a new use case by
adding steps to an existing use case.
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
Example of a Soda Machine Use Case diagram:
Generalization
Classes can inherit from one another, and so can use cases. In use case inheritance, the child use
case inherits behavior and meaning from the parent and adds its own behavior. You can apply the
child wherever you apply the parent.
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
Lab Tasks:
1. Draw a Use Case diagram for a scenario of having a lunch in a restaurant.
2. Draw a Use Case diagram for a Hospital. Identify important actors, use cases and their
relationships.
3. Draw a Use Case diagram for a pizza delivery.
4. Draw a Use Case diagram for a room reservation in a hotel.
CAED Session:-2K22 Computer Lab Instructor:-Adnan Mustafa
Engineering