"Just because you can doesn't mean you should".
In other words: it may be legal to use a state model to define an operation's behaviour - but it doesn't mean you should. I've never come across a scenario where it would have been useful; but of course that doesn't mean they don't exist. It's also symptomatic of the lack of cohesion in some of the UML specification.
It would be appropriate where the operation (not the enclosing class) had stateful behaviour. To use a really contrived example: consider a method TcpConnection.close()
. If the connection was already closed, then calling close()
would have no effect. If the connection was open then calling close()
would close it.
[However: as an example that also illustrates why I've never found the need for a method-specific state model. The state model really belongs with the class, not the operation].
hth.