state pattern: does it make sense to use it if each state is only allowed to perform just 1 or 2 actions? -
1) extreme case: have 10 states , 10 possible actions perform (that result in state transitions). each of these actions allowed in particular state. state 1 can perform action 1, state 2 action 2, , on (a simple graph goes forward)
2) opposite case: have 10 states , 10 possible actions perform, each of them allowed in every state. of them behave in same way among couple of states, behave same in every state , others work differently in each (like strategy)
i have presented 2 extreme scenarios. i'd have opinions on do. combining patterns too.
think of states phases in simple game. have title state, menu state (plus sub-menus inherit main menu state), actual game state, , maybe credits state. each of these individual states has own functionality , purpose, , not shared, else why need own state?
if have functionality shared between states, should sort of inheritance. in example, involve making base menu state, individual menu state each menu (main menu, options menu, graphics menu, audio menu, etc, etc) inherit base menu state. in way, allow some/all functionality shared between states, because purpose of individual states similar.
does help? don't feel can answer actual question unless provide more specific details you're trying accomplish.
Comments
Post a Comment