Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
177 views

Lecture 04 UML Use Case and Class Diagram

The document discusses UML diagrams, specifically focusing on use case diagrams, sequence diagrams, class diagrams, and activity diagrams. It provides an overview of each diagram type, including their key components and how to construct them. Examples of each diagram type are also included to demonstrate their structure and purpose in modeling systems.

Uploaded by

kaosar alam
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
177 views

Lecture 04 UML Use Case and Class Diagram

The document discusses UML diagrams, specifically focusing on use case diagrams, sequence diagrams, class diagrams, and activity diagrams. It provides an overview of each diagram type, including their key components and how to construct them. Examples of each diagram type are also included to demonstrate their structure and purpose in modeling systems.

Uploaded by

kaosar alam
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

UML Diagrams

Ref: Whitten et all, Systems Analysis and Design Methods 7e. McGraw-Hill Higher Education

Mostafijur Rahman Akhond


Lecture, CSE
BRAC University
Key Ideas
• Introduction to UML diagrams
• Use case diagram
• Sequence diagram
• Class diagram
• & Activity diagram

Slide
2
UML diagram
• Stands for Unified Modeling Language
• A language with notion which can be understand by all the parties involved with software

• Initiated by Rational Software in 1994-95


• Popular tools –
• Rational Rose
• Microsoft Visio
• Draw.io

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

• To draw the use case diagram, one need to


• Identify all the entity who will performs action
• And all the actions needed to support by the system

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

• It can also describes the sequence of actions in a system

• Every Use case must have a unique name

• Use case must be started with principal verb Book a ride

• Use cases in the diagram must be enclosed by the system boundary


Figure: An Use case
• Every Use case should be connected with either actor or another use case

• Must be represented by an ellipse

11
System Boundary

• Shows how the system interacts with the user


• Class in which use case are executed
• Represented by the use cases within a rectangle and actors will
outside of the system boundary
Figure: The system boundary of Use case

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

• Represented by a straight line with hollow


arrow Premium Rider Irregular Rider
Figure: Generalization relation between actors

• Can indicate the relation between


• Either Actors pay
online
• Or Use cases

pay with pay with


card bkash

Figure: Generalization relation between use cases


15
Dependency
• Indicates the dependency relationship between two use cases.

• Two types of dependencies : Include & Extend Book a ride

<<include>>

• Include relationships Confirm


the ride
• One use case (base) includes the functionality of another (inclusion case)
• Supports re-use of functionality
Figure: Include relation

Finish the
ride
• Extend relationships <<extend>>
• One use case (extension) extends the behavior of another (base)
Get review

Figure: extend relation


16
Use case Description
• Every use case diagram must have its description
• Usually description is presented in tabular form
• The diagram should have a unique id
• Typically the description form include the fields –
Use case Name, Id, Actor(s), Description, Precondition, Postcondition, Action Flow, Exceptions,
etc.
• All the fields might not be available for all the diagrams.

Figure: An Use case description table


17
Use case example 1 : Purchasing an item

18
Class diagram
What is class diagram

• A class diagram depicts classes and their interrelationships

• Used for describing structure and behavior in the use cases

• Provide a conceptual model of the system in terms of objects and their relationships

• Used for requirement capture, end-user interaction

• Detailed class diagrams are used for developers

20
Class Diagram components

• Class
• Name
• Attributes
• Methods
• Visibility

• Relation
• Generalization
• Association
• Aggregation
• Composition

• Multiplicity

Figure: Class diagram

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

• Generalization expresses a parent/child relationship among


related classes.

• Used for abstracting details in several layers


• Similar notion as use case diagram
Figure: Generalization in class diagram

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

• Courses have exams has enrolls

• Association has two ends


• Role names (e.g. enrolls)
Figure: Association in class diagram

• Multiplicity (e.g. One course can have many students)


• Navigability (unidirectional, bidirectional)

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)

0..1 No or One instance

1 Exactly one instance

1..1 Exactly one instance

0..* Zero or More instances

* Zero or More instances

1..* One or More instances

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

• Identify all the relations


• The “has” in requirements usually maps as relational in class diagram

• After finding the classes/objects and relations- draw the diagram structure

31

You might also like