SPM LAB Manual
SPM LAB Manual
SPM LAB Manual
1 Date:
Aim: To draw one or more Use Case diagrams for capturing and representing requirements
of the system .Use case diagram must include template showing description and steps of the
Use Case for various scenarios. Eg. Library Management System
Theory:
Use Case Diagram captures the system's functionality and requirements by using
actors and use cases. Use Cases model the services, tasks, function that a system needs to
perform. Use cases represent high-level functionalities and how a user will handle the system.
Use-cases are the core concepts of Unified Modelling language modelling.
A Use Case consists of use cases, persons, or various things that are invoking the
features called as actors and the elements that are responsible for implementing the use cases.
Use case diagrams capture the dynamic behaviour of a live system. It models how an external
entity interacts with the system to make it work. Use case diagrams are responsible for
visualizing the external things that interact with the part of the system.
Actor:
It is used inside use case diagrams. The actor is an entity that interacts with the system.
A user is the best example of an actor. An actor is an entity that initiates the use case from
outside the scope of a use case. It can be any element that can trigger an interaction with the
use case. One actor can be associated with multiple use cases in the system. The actor notation
in UML is given below.
Use cases are intended to convey desired functionality so the exact scope of a use case may
vary according to the system and the purpose of creating UML model.
Use Case diagram for LIBRARY MANAGEMENT SYSTEM:
Conclusion: Thus we have successfully studied how to Use Case diagrams for capturing and
representing requirements of the system.
Practical No. 2 Date:
Aim: To draw one or more Package diagram to organise and manage your large and
complex systems as well as their complex models. Eg. ATM Machine
Theory:
Package diagrams are used to structure high level system elements. Packages are used
for organizing large system which contains diagrams, documents and other key deliverables.
Package Diagram can be used to simplify complex class diagrams, it can group classes
into packages.
A package is a collection of logically related UML elements.
Packages are depicted as file folders and can be used on any of the UML diagrams.
Package Diagram at a Glance:-
Package diagram is used to simplify complex class diagrams, you can group classes
into packages. A package is a collection of logically related UML elements.
The diagram below is a business model in which the classes are grouped into packages:
Packages appear as rectangles with small tabs at the top.
The package name is on the tab or inside the rectangle.
The dotted arrows are dependencies.
One package depends on another if changes in the other could possibly force changes
in the first.
Conclusion: Thus we have successfully studied how to Package diagram to organise and
manage large and complex systems as well as their complex models.
Practical No. 3 Date:
Aim: Draw activity diagrams to display either business flows or like flow charts. Eg. Online
Payment Gateways or Campus Recruitment System.
Theory:
We use Activity Diagrams to illustrate the flow of control in a system and refer to the
steps involved in the execution of a use case. We model sequential and concurrent activities
using activity diagrams. So, we basically depict workflows visually using an activity
diagram. An activity diagram focuses on condition of flow and the sequence in which it
happens. We describe or depict what causes a particular event using an activity diagram.
UML models basically three types of diagrams, namely, structure diagrams, interaction
diagrams, and behavior diagrams. An activity diagram is a behavioral diagram i.e. it depicts
the behavior of a system.
An activity diagram portrays the control flow from a start point to a finish point showing
the various decision paths that exist while the activity is being executed. We can depict both
sequential processing and concurrent processing of activities using an activity diagram. They
are used in business and process modelling where their primary use is to depict the dynamic
aspects of a system.
Flowcharts were typically invented earlier than activity diagrams. Non programmers use
Flow charts to model workflows. For example: A manufacturer uses a flow chart to explain
and illustrate how a particular product is manufactured. We can call a flowchart a primitive
version of an activity diagram. Business processes where decision making is involved is
expressed using a flow chart.
Brevity is the soul of wit. We need to convey a lot of information with clarity and make
sure it is short. So an activity diagram helps people on both sides i.e. Businessmen and
Developers to interact and understand systems.
1. Initial State – The starting state before an activity takes place is depicted using the initial
state.
A process can have only one initial state unless we are depicting nested activities. We use
a black filled circle to depict the initial state of a system. For objects, this is the state when
they are instantiated. The Initial State from the UML Activity Diagram marks the entry
point and the initial Activity State.
2. Action or Activity State – An activity represents execution of an action on objects or by
objects. We represent an activity using a rectangle with rounded corners. Basically any
action or event that takes place is represented using an activity.
3. Action Flow or Control flows – Action flows or Control flows are also referred to as
paths and edges. They are used to show the transition from one activity state to another.
8. Merge or Merge Event – Scenarios arise when activities which are not being executed
concurrently have to be merged. We use the merge notation for such scenarios. We can
merge two or more activities into one if the control proceeds onto the next activity
irrespective of the path chosen.
9. Swimlanes – We use swimlanes for grouping related activities in one column. Swimlanes
group related activities into one column or one row. Swimlanes can be vertical and
horizontal. Swimlanes are used to add modularity to the activity diagram. It is not
mandatory to use swimlanes. They usually give more clarity to the activity diagram. It’s
similar to creating a function in a program. It’s not mandatory to do so, but, it is a
recommended practice.
Conclusion: Thus we have successfully studied how to draw Activity diagrams to display
either business flow or like flow charts.
Practical No. 4 Date:
Aim: To draw basic Class diagram to identify and describe key concepts like Classes, types
in your system and their relationship. Eg. Online banking System.
Theory:
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.
A description of a group of objects all with similar roles in the system, which consists of:
Structural features (attributes) define what objects of the class "know"
Represent the state of an object of the class
Are descriptions of the structural or static features of a class
Behavioral features (operations) define what objects of the class "can do"
Define the way in which objects may interact
Operations are descriptions of behavioral or dynamic features of a class
Class Notation
Class Relationships
A class may be involved in one or more relationships with other classes. A relationship can
be one of the following types:
Relationship Type Graphical Representation
Inheritance (or Generalization):
Represents an "is-a" relationship.
An abstract class name is shown in italics.
SubClass1 and SubClass2 are
specializations of Super Class.
A solid line with a hollow arrowhead that
point from the child to the parent class
Simple Association:
A structural link between two peer classes.
There is an association between Class1 and
Class2
A solid line connecting two classes
Aggregation:
A special type of association. It represents a "part
of" relationship.
Class2 is part of Class1.
Many instances (denoted by the *) of Class2
can be associated with Class1.
Objects of Class1 and Class2 have separate
lifetimes.
A solid line with an unfilled diamond at the
association end connected to the class of
composite
Composition:
A special type of aggregation where parts are
destroyed when the whole is destroyed.
Objects of Class2 live and die with Class1.
Class2 cannot stand by itself.
A solid line with a filled diamond at the
association connected to the class of
composite
Dependency:
Exists between two classes if the changes to
the definition of one may cause changes to
the other (but not the other way around).
Class1 depends on Class2
A dashed line with an open arrow
Relationship - Roles
A role is a directional purpose of an association.
Roles are written at the ends of an association line and describe the purpose played by
that class in the relationship.
E.g., A cell is related to an expression. The nature of the relationship is that the
expression is the formula of the cell.
Navigability
The arrows indicate whether, given one instance participating in a relationship, it is possible to
determine the instances of the other class that are related to it.
The diagram above suggests that,
Given a spreadsheet, we can locate all of the cells that it contains, but that
We cannot determine from a cell in what spreadsheet it is contained.
Given a cell, we can obtain the related expression and value, but
Given a value (or expression) we cannot find the cell of which those are
attributes.
Access for each of these visibility types is shown below for members of different classes.
protected
Access Right public (+) private (-) Package (~)
(#)
Conclusion: Thus we have successfully studied how to draw basic Class diagram to identify
and describe key concepts.
Practical No. 5 Date:
Aim: To draw advanced class diagrams to depict advanced relationships, other classifiers
like interfaces. Eg. Executing a complex computer program
Theory:
There are several software available which can be used online and offline to draw these
diagrams Like Edraw max, lucid chart etc. There are several points to be kept in focus while
drawing the class diagram. These can be said as its syntax:
Each class is represented by a rectangle having a subdivision of three compartments
name, attributes and operation.
There are three types of modifiers which are used to decide the visibility of attributes and
operations.
+ is used for public visibility(for everyone)
# is used for protected visibility (for friend and derived)
– is used for private visibility (for only me)
Below is the example of Animal class (parent) having two child class as dog and cat both have
object d1, c1 inheriting properties of the parent class.
import java.io.*;
class GFG {
public static void main(String[] args)
{
dog d1 = new dog();
d1.bark();
d1.run();
cat c1 = new cat();
c1.meww();
}
}
class Animal {
public void run()
{
String name;
String colour;
System.out.println("animal is running");
}
}
class dog extends Animal {
public void bark()
{
System.out.println("wooh!wooh! dog is barking");
}
public void run()
{
System.out.println("dog is running");
}
}
class cat extends Animal {
public void meww()
{
System.out.println("meww! meww!");
}
}
Process to design class diagram:
In Edraw max (or any other platform where class diagrams can be drawn) follow the steps:
Open a blank document in the class diagram section.
From the library select the class diagram and click on create option.
Prepare the model of the class in the opened template page.
After editing according to requirement save it.
There are several diagram components which can be efficiently used while making/editing the
model. These are as follows:
Class { name, attribute, method}
Objects
Interface
Relationships {inheritance, association, generalization}
Associations {bidirectional, unidirectional}
Class diagrams are one of the most widely used diagrams in the fields of software engineering
as well as businesses modelling.
Class Diagram for Executing a complex computer program:
Theory:
1. Actors – An actor in a UML diagram represents a type of role where it interacts with the
system and its objects. It is important to note here that an actor is always outside the scope
of the system we aim to model using the UML diagram.
We use actors to depict various roles including human users and other external subjects.
We represent an actor in a UML diagram using a stick person notation. We can have
multiple actors in a sequence diagram.
For example – Here the user in seat reservation system is shown as an actor where it
exists outside the system and is not a part of the system.
Figure – an actor interacting with a seat reservation system
Figure – lifeline
We display a lifeline in a rectangle called head with its name and type. The head is located
on top of a vertical dashed line (referred to as the stem) as shown above. If we want to
model an unnamed instance, we follow the same pattern except now the portion of
lifeline’s name is left blank.
Difference between a lifeline and an actor – A lifeline always portrays an object
internal to the system whereas actors are used to depict objects external to the system.
The following is an example of a sequence diagram:
Self Message – Certain scenarios might arise where the object needs to send a
message to itself. Such messages are called Self Messages and are represented with
a U-shaped arrow.
Reply Message – Reply messages are used to show the message being sent from
the receiver to the sender. We represent a return/reply message using an open
arrowhead with a dotted line. The interaction moves forward only when a reply
message is sent by the receiver.
Used to model and visualise the logic behind a sophisticated function, operation or
procedure.
They are also used to show details of UML use case diagrams.
Used to understand the detailed functionality of current or future systems.
Visualise how messages and tasks move between objects or components in a system.
Theory:
A state machine diagram models the behaviour of a single object, specifying the sequence of
events that an object goes through during its lifetime in response to events.
As an example, the following state machine diagram shows the states that a door goes through
during its lifetime.
The door can be in one of three states: "Opened", "Closed" or "Locked". It can respond to
the events Open, Close, Lock and Unlock. Notice that not all events are valid in all states; for
example, if a door is opened, you cannot lock it until you close it. Also notice that a state
transition can have a guard condition attached: if the door is Opened, it can only respond to the
Close event if the condition doorWay->isEmpty is fulfilled. The syntax and conventions used
in state machine diagrams will be discussed in full in the following sections.
States
A state is denoted by a round-cornered rectangle with the name of the state written inside it.
The initial state is denoted by a filled black circle and may be labeled with a name. The
final state is denoted by a circle with a dot inside and may also be labeled with a name.
Transitions
Transitions from one state to the next are denoted by lines with arrowheads. A transition
may have a trigger, a guard and an effect, as below.
"Trigger" is the cause of the transition, which could be a signal, an event, a change in some
condition, or the passage of time. "Guard" is a condition which must be true in order for the
trigger to cause the transition. "Effect" is an action which will be invoked directly on the object
that owns the state machine as a result of the transition.
State Actions
In the transition example above, an effect was associated with the transition. If the target
state had many transitions arriving at it, and each transition had the same effect associated with
it, it would be better to associate the effect with the target state rather than the transitions. This
can be done by defining an entry action for the state. The diagram below shows a state with an
entry action and an exit action.
It is also possible to define actions that occur on events, or actions that always occur. It is
possible to define any number of actions of each type.
Self-Transitions
A state can have a transition that returns to itself, as in the following diagram. This is most
useful when an effect is associated with the transition.
Compound States
A state machine diagram may include sub-machine diagrams, as in the example below.
Entry Point
Sometimes you won’t want to enter a sub-machine at the normal initial state. For example,
in the following sub-machine it would be normal to begin in the "Initializing" state, but if for
some reason it wasn’t necessary to perform the initialization, it would be possible to begin in
the "Ready" state by transitioning to the named entry point.
The following diagram shows the state machine one level up.
Exit Point
In a similar manner to entry points, it is possible to have named alternative exit points. The
following diagram gives an example where the state executed after the main processing state
depends on which route is used to transition out of the state.
Choice Pseudo-State
A choice pseudo-state is shown as a diamond with one transition arriving and two or more
transitions leaving. The following diagram shows that whichever state is arrived at, after the
choice pseudo-state, is dependent on the message format selected during execution of the
previous state.
Junction Pseudo-State
Junction pseudo-states are used to chain together multiple transitions. A single junction can
have one or more incoming, and one or more outgoing, transitions; a guard can be applied to
each transition. Junctions are semantic-free. A junction which splits an incoming transition into
multiple outgoing transitions realizes a static conditional branch, as opposed to a choice
pseudo-state which realizes a dynamic conditional branch.
Terminate Pseudo-State
Entering a terminate pseudo-state indicates that the lifeline of the state machine has
ended. A terminate pseudo-state is notated as a cross.
History States
A history state is used to remember the previous state of a state machine when it was
interrupted. The following diagram illustrates the use of history states. The example is a state
machine belonging to a washing machine.
In this state machine, when a washing machine is running, it will progress from "Washing"
through "Rinsing" to "Spinning". If there is a power cut, the washing machine will stop running
and will go to the "Power Off" state. Then when the power is restored, the Running state is
entered at the "History State" symbol meaning that it should resume where it last left-off.
Concurrent Regions
A state may be divided into regions containing sub-states that exist and execute
concurrently. The example below shows that within the state "Applying Brakes", the front and
rear brakes will be operating simultaneously and independently. Notice the use of fork and join
pseudo-states, rather than choice and merge pseudo-states. These symbols are used to
synchronize the concurrent threads.
Conclusion: Thus, we have successfully studied state machine to model the behaviour of a
single object, specifying the sequence of events that an object goes through during its lifetime
in response to events.
Practical No. 8 Date:
Aim: Draw component diagrams assuming that you will build your system reusing existing
components along with a few new ones. Eg. Development of bio-inspired algorithms to
solve complex computational or real-life problems.
Theory:
Component diagrams are often drawn to help model implementation details and double-
check that every aspect of the system's required function is covered by planned development.
In the first version of UML, components included in these diagrams were physical:
documents, database table, files, and executables, all physical elements with a location.
In the world of UML 2, these components are less physical and more conceptual stand-
alone design elements such as a business process that provides or requires interfaces to interact
with other constructs in the system.
The physical elements described in UML 1, like files and documents, are now referred
to as artifacts.
A UML 2 component may contain multiple physical artifacts if they naturally belong
together.
Component
A component is a logical unit block of the system, a slightly higher abstraction than classes. It
is represented as a rectangle with a smaller rectangle in the upper right corner with tabs or the
word written above the name of the component to help distinguish it from a class.
Interface
An interface (small circle or semi-circle on a stick) describes a group of operations used
(required) or created (provided) by components. A full circle represents an interface created or
provided by the component. A semi-circle represents a required interface, like a person's input.
Dependencies
Draw dependencies among components using dashed arrows.
Port
Ports are represented using a square along the edge of the system or a component. A port is
often used to help expose required and provided interfaces of a component.
Take stock of everything needed to implement the planned system. For example, for a
simple e-commerce system, you'll need components that describe products, orders,
and customer accounts.
Create a visual for each of the components.
Describe the organization and relationships between components using interfaces,
ports, and dependencies.
Package diagram elements are always public, while component diagram elements are
private.
Component Diagram for Online Shopping: