0% found this document useful (0 votes)
20 views41 pages

Unit-3 Unit-5 - Relatable Topic - Lecture

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views41 pages

Unit-3 Unit-5 - Relatable Topic - Lecture

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Software Engineering

BTECH – CSE (3rd Semester )


Unit-3 (FSM , State Diagram )

Presented By
DEEPTI GOUR
FSM – Finite State Machine
2

Finite State Machines come from a branch of Computer Science called “automata
theory”. The family of data structure belonging to this domain also includes
the Turing Machine.

A Finite State Machine, or FSM, is a computation model that can be used to simulate
sequential logic, or, in other words, to represent and control execution flow.

A Finite State Machine is a model of computation based on a hypothetical machine


made of one or more states. Only one single state of this machine can be active at
the same time. (It means the machine has to transition from one state to another in
to perform different actions.)

A Finite State Machine is any device storing the state of something at a given time.
The state will change based on inputs, providing the resulting output for the
implemented changes.
Finite State Machines can be used to model problems in many fields, including
mathematics, artificial intelligence, games or linguistics.
3
Coin-operated turnstile
States: locked, unlocked
Transitions: pointing a coin in the slot will unlock the turnstile, pushing the arm of the unlocked turnstile will let
the costumer pass and lock the turnstile again

Traffic Light
States: Red, Yellow, Green
Transitions: After a given time, Red will change to Green, Green to Yellow, and Yellow to Red

Programming example
Knowing what we know, let’s make a simple and basic programming example. Let’s say we have our friend
Mario in our favorite video game. So, Mario can do the following actions:
• Stand still
• Run
• Jump
• Duck

For example,(Mario Game) - Mario can stand still then run when we push the corresponding button, but cannot
run while he is jumping. So, an input that doesn’t cause a change of state is ignored.
FSM Model in detail 4

An FSM is a model for describing an entity / elements – that characterized by its


operation and behavior.

In a system, when numbers of states are finite, then the system is called a Finite State
Machine.

A finite-state machine (FSM) or finite-state automaton (FSA, plural: automata), finite


automaton, or simply a state machine, is a mathematical model of computation. ... The
FSM can change from one state to another in response to some inputs; the change
from one state to another is called a transition.

The main design tool for FSM is the State Transition Diagram (STD). Also called a
state diagram or bubble diagram, the depicts the relationship between the system
state.
5
6

How To Implement an FSM


• The Finite State Machine class keeps track of the current state, and the
list of valid state transitions.
• You define each transition by specifying :
• FromState - the starting state for this transition
• ToState - the end state for this transition
• condition - a callable which when it returns True means this transition
is valid
• callback - an optional callable function which is invoked when this
transition is executed.
7
Shut-Down – Coffee Machine
8
9
UML Modeling
A Model is an element that contains information for a software model.
A View is a visual expression of the information contained in a model, and
a Diagram is a collection of view elements that represent the user’s specific design
thoughts.

UML is a standard language for specifying , visualizing, constructing , and documenting the
artifacts of software systems.
UML was created by Object Management Group and UML specification draft (1st Version ) was
proposed in OMG in January 1997.
UML is a graphical notation for modeling various aspects of software systems.
UML Diagram Types 10
UML Diagram Types (UML Diagrams are divide into two types )
1. Structural UML Diagram 2. Behavioral UML Diagram
• represent the static aspects of the • represent the dynamic aspects of the
system system.
• show the things in the modeled • show what should happen in a system.
system. In a more technical term, They describe how the objects interact
they show different objects in a with each other to create a functioning
system. system.
1. Class Diagram 1. Activity Diagram
2. Object Diagram 2. Use Case Diagram
3. Component Diagram 3. Interaction Overview Diagram
4. Composite Structure Diagram 4. Timing Diagram
5. Deployment Diagram 5. State Machine Diagram
6. Package Diagram 6. Communication Diagram
7. Profile Diagram 7. Sequence Diagram
11
1. Class Diagram

Class diagrams are the


main building block of
any object-oriented
solution. It shows the
classes in a system,
attributes, and
operations of each
class and the
relationship between
each class. Class Diagram for Order Processing

A class has three parts.


1.Name at the top,
2.attributes in the
middle
3.operations or
methods at the bottom.
12
2. Object Diagram
sometimes referred to as Instance diagrams are very similar to class diagram .
Like class diagram, it also show the relationship between objects.(Use real
world scenario problems)
It show what a system will look like at a given time, Cause - data available in the
objects & they are used to explain complex relationships between objects.
3. Component Diagram 13

Component UML
diagrams can help break
down the (Project or
Software ) system into
smaller components
when dealing with the
documentation of quite
complex systems. Often
it is quite hard to predict
the architecture of a
system since it might
encompass various
departments or employ
different technologies.
4.Deployment Diagram 14

Deployment diagrams are generally used in visualizing the relationship


between the software and hardware. If we talk more precisely, then with the
help of deployment diagrams, we can also construct a physical model of how
artifacts are deployed on hardware components nodes.

Deployment diagrams are effective for visualizing, specifying, and


documenting the following types of systems:

Embedded systems that use hardware that is controlled by external stimuli;


for example, a display that is controlled by temperature change.

Client/server systems that typically distinguish between the user interface


and the persistent data of a system.

Distributed systems that have multiple servers and can host multiple
versions of software artifacts, some of which might even migrate from node
to node
15
16
5. Package Diagram

Packages group related model elements of all types, including other packages.
User can group model elements in packages for the following reasons: Organize
the model elements so that the model is easier to understand and to navigate in the
Project Explorer.
Model the architecture of your system by using packages to represent the various
layers or subsystems (that must be unique)

Packages also represent namespaces, which means that the model elements within
a package must have unique names.

For example, if you validate a model that has an actor named Customer and a class
named Customer in the same package, you will receive a warning that conflicting
names appear in the same package. To prevent the warning, you can put the
Customer actor in another package.
You can use packages in several diagrams, including class, component, and use-
case diagrams. Each package has a unique name that describes its content.
17
18
19
20
6. Composite Structure Diagram
composite structure diagram depicts the internal structure of structured
classifiers by using parts, ports, and connectors. A structured classifier defines
the implementation of a classifier and can include a class, a component, or a
deployment node.
You can use the composite structure diagram to show the internal details of a
classifier and to describe the objects and roles that work together to perform the
behavior of the containing classifier.

A composite structure diagram is similar to a class diagram, but it depicts


individual parts instead of whole classes. Before you can define the internal
structure of a classifier, you must either show its structure compartment or open
a composite structure diagram

In composite structure diagrams, ports define the interaction point between a


classifier and its environment or between a classifier and its internal parts. You
can use a port to specify the services that a classifier provides to and requires from
its environment.
Parts :In composite structure diagram - part is a diagram element that represents a set 21
of one or more instances that a containing structured classifier owns.

Ports: In composite structure diagrams, a port defines the interaction point between a
classifier instance and its environment or behavior of the classifier and its internal parts.

Collaborations: A collaboration is a type of structured classifier in which roles and


attributes co-operate to define the internal structure of a classifier.
You use a collaboration when you want to define only the roles and connections that are
required to accomplish a specific goal of the collaboration.

Collaboration uses : In composite structure diagrams, a collaboration use is model


element that represents one use of a collaboration to explain the relationships between
the parts of a structured classifier. User may use a collaboration use to apply a pattern,
which is described by a collaboration, to a specific situation that involves classes or
instances that play the roles of the specified collaboration.

Connectors in structured classifiers: In UML diagrams, a connector is a line that


represents a relationship in a model. When you model the internal structure of a
classifier, you can use a connector to indicate a link between two or more instances of a
part or a port.
22
23
24
Profile Diagram

Profiles provide a means of extending the UML. They are based on additional
stereotypes and Tagged Values that are applied to UML elements, connectors and their
components. A Profile is a collection of such extensions that together describe some
particular modeling problem and facilitate modeling constructs in that domain.

Profile The first stage in creating a UML Profile is to create a Profile


Package that has the stereotype «profile» in your technical
development model.
Stereotype Stereotype elements represent the way in which each object is
extended.
Metaclass Metaclass elements represent the types of object that you are
extending in your Profile Package.
Enumeration An Enumeration is a data type, whose instances can be any of a
number of user-defined enumeration literals.
25
Behavioral Diagram 8. Activity Diagram 26

Activity diagrams are used to model system behaviors, and the way in which
these behaviors are related in an overall flow of the system (that is, dynamic
element interactions).

The logical paths a process follows, based on various conditions, concurrent


processing, data access, interruptions and other logical path distinctions, are
all used to construct a process, system or procedure.
27
Step 1: Identify the Process Determine the process/entities you want to represent
in the activity diagram.

Step 2: Identify Activities Break down the complex process into distinct activities
or actions involved.

Step 3: Start and End Nodes Draw a rounded rectangle to represent the start and
end of the process.

Step 4: Add Activities Use rectangles to represent activities. Connect them using
arrows to indicate the flow of the process.

Step 5: Decision Points Use a diamond-shaped symbol to represent decision


points or conditions that affect the process flow.

Step 6: Connect Activities and Decisions Connect activities and decision points
with arrows. Based on the decision outcome, create branches using arrows
to represent different paths.
Symbols Used in Activity Diagrams 28

Start/End: Circle
A small filled circle that symbolizes the initial state or the start of
the activity (initial node).

Activity/Action/Activity nodes: Rectangle


A rectangle with rounded corners that symbolizes an activity or
action state (receive order, fill order, etc)

Decision Point: Diamond


It is represented by a decision with alternate paths. It is like a
flowchart where the decision is to be made by diamond.
Action flow:
An arrow that represents the transition from one activity or action
to another. Also called activity edge or control flow.

Fork node and join node:


Both are represented by a thick horizontal line that splits an action
into concurrent flows (fork node) or joins concurrent flows into a
single action (join node).
Transition/Flow:
Arrows connecting activities and decisions
29
30
31
32
9. Use Case diagrams
• Use Case diagrams capture Use Cases and the relationships between Actors and the
subject (system).
• Describe the functional requirements of the system
• Describe the manner in which outside things (Actors) interact at the system
boundary
• Describe the response of the system
Where the Use Case Helpful?
• Before starting a project, you can create use-case diagrams to model a business so
that all participants in the project share an understanding of the workers,
customers, and activities of the business.
• While gathering requirements, you can create use-case diagrams to capture the
system requirements and to present to others what the system should do.
• During the analysis and design phases, you can use the use cases and actors from
your use-case diagrams to identify the classes that the system requires.
• During the testing phase, you can use use-case diagrams to identify tests for the
system.
33
The following topics describe model elements in use-case diagrams:
Use cases
A use case describes a function that a system performs to achieve the user’s goal. A use case must
yield an observable result that is of value to the user of the system.
Actors
An actor represents a role of a user that interacts with the system that you are modeling. The user
can be a human user, an organization, a machine, or another external system.
Subsystems
In UML models, subsystems are a type of stereotyped component that represent independent,
behavioral units in a system. Subsystems are used in class, component, and use-case diagrams to
represent large-scale components in the system that you are modeling.
Relationships in use-case diagrams
In UML, a relationship is a connection between model elements. A UML relationship is a type of
model element that adds semantics to a model by defining the structure and behavior between the
model elements.
34
35
Interaction Overview Diagram
Interaction overview diagrams provide overview of the flow of control where nodes of the
flow are interactions .
Interaction Diagram while in other places interaction overview diagrams are referred to as
specialization of activity diagram.
The inline interactions and interaction uses are considered as special forms of call behavior
action.
UML diagram requires branching and joining of branches in interaction overview diagrams to
be properly nested. This is more restrictive than in activity diagrams and could be quite
difficult to obey.

he following elements used on the interaction overview diagrams:


1. initial node
2. flow final node
3. activity final node
4. decision node
5. merge node
6. fork node
7. join node
36
State Machine Diagrams 37
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.

it is mainly used to analyze the object states influenced by events. This analysis is helpful to
understand the system behavior during its execution.
To identify the events responsible for state changes and Forward and reverse engineering.
1. States
A state is denoted by a round-cornered rectangle
with the name of the state written inside it.
2. Initial and Final States
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.
3. 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.
Self-Transitions 38
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,

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.

Choice Pseudo-State
A choice pseudo-state is shown as a diamond with one transition arriving and two or more
transitions leaving.

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.
39

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.
40
Thanks

You might also like