[Cs3] State pattern
Mikhail Nesterenko
mikhail at cs.kent.edu
Wed Dec 13 20:46:33 EST 2017
context: the class of objects whose state is being maintained through
state class. Delegates behaviors for state class to be
implemented.
abstract state: defines the interface of behaviors to be implemented
in each state
concrete state: implements behaviors. Part of the implementation is
the transition of the context from one (concrete) state to another.
Thanks,
--
Mikhail
Donald Harmon wrote:
> Hello again Mikhail,
>
> I have a last minute question about the State design pattern.
>
> In the sample Final exam, question number 5 asks:
> Explain the purpose of the context class, abstract state class and concrete
> state class.
>
>
> I just want to make sure I am on the right track with my answer, and if
> not, figure out what the purpose actually is.
>
>
> My answer:
> The purpose of the context class is to provide the client with an interface
> to interact with. Context objects have states and pass operations to the
> state class.
>
> The purpose of the abstract state class is to provide default
> implementations of operations and ensure the correct operation is called
> (concrete state operation) based upon the state of the context.
>
> The purpose of the concrete state(s) is to define the state change
> operations that affect the state of the context, and provide different
> behavior based upon the state of the context.
>
More information about the cs3
mailing list