Lecture 04 UML Use Case and Class Diagram
Lecture 04 UML Use Case and Class Diagram
Ref: Whitten et all, Systems Analysis and Design Methods 7e. McGraw-Hill Higher Education
Slide
2
UML diagram
• Stands for Unified Modeling Language
• A language with notion which can be understand by all the parties involved with software
3
Different Types of UML
4
Use case diagram
What is Use Case ?
• Use case diagrams considers mostly as a requirement analysis tools
• It identifies the uses of the system based on a case
• Use indicates the actions
• Case indicates the action linked with actor (who performs the action)
• All the action verbs mentioned in requirement specification is an use case in this diagram
6
Components of Use Case diagram
• Use case diagram is composed of four components
• Actor
• Use case
• System boundary
• Relations
7
Actor
• The entity which performs the actions or roles in the system
• Actor is responsible for giving input to the system
• Responsible to use processed output for performing particular
action
• Actor must be connected with at least one use case
• Four types of Actors can be involved in use case –
• Primary actor
Figure: Actor in Usecase
• Secondary actor
• External hardware
• Other System
8
Types of Actor
Primary actor
• People who performs the main system functions.
• For example rider of a ride sharing system. As s/he is requesting for ride, or paying the money
using the system.
Secondary actor
• People who performs the administrative functions.
• For the aforementioned system a manager who sets the discounts is an example of Secondary
actor.
9
Types of Actor (cont.)
External hardware
• Any external hardware device which is a part of the application.
• If the system using amazon datastore as their database.
Other System
• Any external system which has interaction with the current system.
• Payment gateway is an example of such actor.
10
Use Cases
• Indicates the system functions performed by an actor
11
System Boundary
12
Relation
• Also Known as by communication line
• It represents the connection between any two components
of use case diagram
• Can be of three types
• Association
• Generalization
• Dependency
13
Association
• Connects an actor with the use case
• Identifies the actor(s) are responsible/user of the use case
• Represented by a straight solid line
• No arrow
• Not dashed or curved line
Book a
• A actor must have at least one association in the diagram Rider
ride
• An use case can be associated with zero or more actors Figure: association between an
actor and an use case
14
Generalization
• Represents the parent-child relation Rider
<<include>>
Finish the
ride
• Extend relationships <<extend>>
• One use case (extension) extends the behavior of another (base)
Get review
18
Class diagram
What is class diagram
• Provide a conceptual model of the system in terms of objects and their relationships
20
Class Diagram components
• Class
• Name
• Attributes
• Methods
• Visibility
• Relation
• Generalization
• Association
• Aggregation
• Composition
• Multiplicity
21
Class
• Class in a class diagram contains three parts – top, middle and bottom
contains the name of the class. It is printed in bold and centered, and the first
Top
letter is capitalized.
middle compartment contains the attributes of the class. They are left-aligned
Middle and the first letter is lowercase.
bottom compartment contains the operations the class can execute. They are
Bottom
also left-aligned and the first letter is lowercase.
22
Visibility
• Public (+)
• Private (-)
• Protected (#)
• Package (~)
• Derived (/)
• For example age is a derived attribute from date of birth
• Static (underlined)
23
Relation notions in class diagram
24
Generalization
• Inheritance is a required feature of Object Orientation
Programming
25
Association
• Represent relationships between classes.
• Place association names above, on, or below the association line.
• Represent relationship between instances of classes
• Student enrolls in a course
Enrollment
• Courses have students Student * 4 Course
26
Aggregation
• Represents “has a" relationship between classes.
• Aggregation is a directional relationship
• The hollow rectangle indicates the master in the relation
• When the container is destroyed, the contents are usually not destroyed
• For example - a professor has students, when the professor dies the students don't die along with him or her.
27
Composition
• Denotes a strong ownership between two classes
• Composition is also a directional relationship
• The filled rectangle indicates the master in the relation
• When the container is destroyed, the contents are also destroyed
• For example – an IC has transistors, when the IC is dumped the transistors are also dumped with the
circuit.
28
Multiplicity
Notion Meaning
0 No instances (rare)
29
Example Diagram
30
How to draw the Class diagram
• Identify all the objects from the requirement
• The proper nouns from the requirement becomes the class usually
• Identify the hierarchy between the classes (if any) based on the common attributes and
functions
• After finding the classes/objects and relations- draw the diagram structure
31