But it can be discussed in specific context.
I just gave an example when team (OO freshmen) could not accept state
"mechanics" inside business, therefore we split it. So mentally
wrapper and aggregate were one thing (just like command and handler
are actually Command Design Pattern). But people felt better when code
was splited in 2 files - with all consequences including loosing of
encapsulation.
I think we can skip this topic and treat is just like a curiosity:)
I think we can skip this topic and treat is just like a curiosity:)
btw: state machines are powerful tools to deal with complex problems,
we just don't know them or we have bad experience from school:
http://www.skorks.com/2011/09/why-developers-never-use-state-machines/
They also help to "make explicit what is implicit" - i love this
principle by Eric Evans.
According to using them in some class of GUI problems: what really
taught me that state machine is a "must have" is understanding how
simple graphical tools works, like MS Paint or Gimp.
So we have a canvas.
When pressing toll (brush, rubber, etc) on the tool box, we switch
state on the canvas.
When clicking/moving/dragging mouse on canvas, canvas delegates job to
the current state.
Canvas pass itself as a parameter to the state "doJob" method; canvas
provides some simple api like putting pixel of given color at x,y
We can go even further...
Canvas can accept Commands sent by current state.
Each command can have method called getAntiCommand, so when running a
command we put anti-commant on the stack.
ctrl+z uses anticommands from the stack.
Now it's simple... isn't it?
Jut to switch context form business models to something more funny:)