The state is not only specific
to programming language but there are numerous examples of state everywhere
around us,
Like:
Ice Cream is frozen, - ice cream is at
frozen state
Coffee is Hot- coffee is in a hot
state.
Radio is on. – Radio is at on state
The state presents the attribute value
of an object. In terms of Computer Science, a system is called a stateful
if it is designed to remember preceding instruction or user input, Hence the
remembered information is called the state of that system.
The inputs in a computer program are
stored as variables or constants
On execution of the computer program,
it may not only change the state of variables but also it can change the
values that are stored in memory.
For instance: In a loop, as variable
get changes it also changes the state of the program at every iteration.
What
makes a State? | What constitute a state?
The state is made by the value which
the object attribute is having at that particular time. So the object and their
attribute jointly make a state.
Example: if a student is a topper in the college, so
his GPA or his total grades will decide whether he is a normal student or in
the top 10 students. If these attributes like marks or GPA changes then the
state will also get changed from normal to top 10 students or top 10 to the
normal student.
Here, the student is an object,
his position is a state.
What
is Transition?
When an object
moves from one state to another state is called transition.
Completeness
of state
A state will be called completed when
it satisfying the certain condition called “Guard Condition” and move to
another state.
Example: if a student is a topper in the college, so
his GPA or his total grades will decide whether he is a normal student or in
the top 10 students. If these attributes like marks or GPA are 3.5 then the
state of the student will get changed from normal to top 10 students.
Here, student is an object, GPA 3.5 is a
guard condition.
State
in puzzle – Vs - State in Game.
In fact Puzzle & Game is a computer
program. And on the execution of the computer program, it may not only change
the state of variables but also it can change the values that are stored
in memory.
In the game present state is
there because of the last input and the next state depends on the next input,
so the state is getting changes on every new move. But in puzzle state remains
the same.
0 Comments