Redesign using State Design Pattern -doubts -


i want redesign code using state design pattern. states belong specific objects.

example:

class can have 3 states: st1, st2, st3.

similarly, class, b, can have 2 states: st4, st5.

there case class c has 1 state: st1 , st4 , st5.

basically these states should interchangeable in case of complex objects.

also, these classes a, b, , c contain data specific them used states.

my question is: how should state machine designed? should there individual sm every class? can states have common base interface?

please me out; can ask me more questions if need more info.

my question how should state machine designed ,should there individual sm every class ?

if understand description, answer "yes", each object require own state machine.

can states have common base interface ?

a common interface implies common api multiple implementations. common methods each state have, , how implementations differ state?

you may not need class each state if there's no different behavior. may have state class , fsm manages collection of states , rules govern transitions.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -