Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Assignment

SE-401

BSCS (3rd semester)

Sec (B)

Topic: - Class Diagram, Activity Diagram, Sequence Diagram, Use-Case


Diagram

Submitted To: -

Miss Fasiha Naaz

Submitted By: -

Minahel Noor Fatima


What is Class Diagram ?

In software engineering, a class diagram in the Unified Modeling


Language (UML) is a type of static structure diagram that describes
the structure of a system by showing the system's classes, their
attributes, operations (or methods), and the relationships among
objects.

Class diagram shows a collection of classes, interfaces, associations,


collaborations, and constraints. It is also known as a structural
diagram.
Purpose of Class Diagrams

The purpose of class diagram is to model the static view of an


application. Class diagrams are the only diagrams which can be directly
mapped with object-oriented languages and thus widely used at the
time of construction.

 Shows static structure of classifiers in a system


 Diagram provides a basic notation for other structure diagrams
prescribed by UML
 Helpful for developers and other team members too
 Business Analysts can use class diagrams to model systems from a
business perspective.

Class Notation

A class notation consists of three parts:

Class Name

 The name of the class appears in the first partition.


 The name of the class is only needed in the graphical
representation of the class. It appears in the topmost
compartment. A class is the blueprint of an object which can
share the same relationships, attributes, operations, &
semantics. The class is rendered as a rectangle, including its
name, attributes, and operations in separate compartments.
Following rules must be taken care of while representing a
class:

1. A class name should always start with a capital letter.


2. A class name should always be in the center of the first
compartment.
3. A class name should always be written in bold format.
4. UML abstract class name should be written in italics format.

Class Attributes

 Attributes are shown in the second partition.


 The attribute type is shown after the colon.
 Attributes map onto member variables (data members) in
code.

Attributes characteristics

1. The attributes are generally written along with the visibility


factor.
2. Public, private, protected and package are the four visibilities
which are denoted by +, -, #, or ~ signs respectively.
3. Visibility describes the accessibility of an attribute of a class.
4. Attributes must have a meaningful name that describes the use
of it in a class.

Class Operations (Methods)

 Operations are shown in the third partition. They are


services the class provides.
 The return type of a method is shown after the colon at the
end of the method signature.
 The return type of method parameters is shown after the
colon following the parameter name.

Class diagrams are one of the most widely used diagrams in the fields
of software engineering as well as business modeling.

The exact meaning of the arrows:

Benefits of Class Diagram

1. Class Diagram Illustrates data models for even very complex


information systems
2. It provides an overview of how the application is structured
before studying the actual code. This can easily reduce the
maintenance time
3. It helps for better understanding of general schematics of an
application.
4. Allows drawing detailed charts which highlights code required to
be programmed
5. Helpful for developers and other stakeholders.
Example of UML Class Diagram

Creating a class diagram is a straightforward process. It does not


involve many technicalities. Here, is an example:

ATMs system is very simple as customers need to press some


buttons to receive cash. However, there are multiple security
layers that any ATM system needs to pass. This helps to prevent
fraud and provide cash or need details to banking customers.

Below given is a UML Class Diagram example


Here, are some points which should be kept in mind while
drawing a class diagram:

1. The name given to the class diagram must be meaningful.


Moreover, It should describe the real aspect of the system.
2. The relationship between each element needs to be identified in
advance.
3. The responsibility for every class needs to be identified.
4. For every class, minimum number of properties should be
specified. Therefore, unwanted properties can easily make the
diagram complicated.
5. User notes should be included whenever you need to define some
aspect of the diagram. At the end of the drawing, it must be
understandable for the software development team.
6. Lastly, before creating the final version, the diagram needs to be
drawn on plain paper. Moreover, it should be reworked until it is
ready for final submission.

Activity Diagram

Activity diagrams represent workflows in a graphical way. They can be


used to describe the business workflow or the operational workflow of
any component in a system. Sometimes activity diagrams are used as an
alternative to State machine diagrams.

Example of an activity diagram for order management system. In


the diagram, four activities are identified which are associated with
conditions. One important point should be clearly understood that an
activity diagram cannot be exactly matched with the code. The activity
diagram is made to understand the flow of activities and is mainly used
by the business users

Following diagram is drawn with the four main activities −

1. Send order by the customer


2. Receipt of the order
3. Confirm the order
4. Dispatch the order

After receiving the order request, condition checks are performed to


check if it is normal or special order. After the type of order is
identified, dispatch activity is performed and that is marked as the
termination of the process.
Sequence Diagram

The sequence diagram has four objects (Customer, Order, Special-


order and Normal Order).

The following diagram shows the message sequence for Special Order
object and the same can be used in case of Normal Order object. It is
important to understand the time sequence of message flows. The
message flow is nothing but a method call of an object.

The first call is send Order () which is a method of Order object. The
next call is confirm () which is a method of special-order object and
the last call is Dispatch () which is a method of special-order object.
The following diagram mainly describes the method calls from one
object to another, and this is also the actual scenario when the system
is running.
Use Case Diagram

As the most known diagram type of the behavioral UML types, Use
case diagrams give a graphic overview of the actors involved in a
system, different functions needed by those actors and how these
different functions interact.

It’s a great starting point for any project discussion because you can
easily identify the main actors involved and the main processes of the
system.

Use Case Diagram - Vehicle Sales Systems

The figure below shows a use case diagram example for a vehicle
system. As you can see even a system as big as a vehicle sales system
contains not more than 10 use cases! That's the beauty of use case
modeling.

The use case model also shows the use of extend and include. Besides,
there are associations that connect between actors and use cases.

You might also like