"Just because you can doesnโt mean what you need."
In other words: it may be legal to use a state model to determine the behavior of an operation, but that does not mean that you should. I have never come across a scenario where this would be useful; but, of course, this does not mean that they do not exist. It is also a symptom of lack of grip in some UML specifications.
It would be appropriate for the operation (and not the enclosing class) to have stateful behavior. To use a really far-fetched example: consider the TcpConnection.close() method. If the connection has already been closed, calling close() will have no effect. If the connection was open, calling close() will close it.
[However: as an example, which also illustrates why I never found the need for a state model for a particular method. The state model really belongs to the class, not the operation].
NTN.
source share