On website uml-diagrams.org it is mentioned that state machine diagram is a behavior diagram which shows discrete behavior of a part of designed system through finite state transitions. To the best of my knowledge, state charts represent the states of a single object of a certain class. What is meant by part of the system in this case? Can state diagram represent something other than one object?
1 Answer
Can state diagram represent something other than one object?
Yes. A state diagram shows the states and transitions of a single instance of something. That something can be a class (in which case the instance is called an object), but it can also be a larger structure, like a module, sub-system or even the entire system.
If you take the classic example of an ATM, you can draw a state diagram of an ATM, but in most cases you will further decompose your ATM (sub-)system into multiple classes because it is just too much to handle it all in a single class.
-
Does this mean I can represent a sub-system, which for example, includes state such as authenticating, displaying menu, updating database, etc, with events/guards such as enter username, [valid username], click on update, etc. ??? Then how this would differ from flow chart? Nov 15, 2021 at 8:30
-
yes, technically you can do it. Practically it will be more difficult to read than other approaches. But the language itself lets you do it.– IsterNov 15, 2021 at 8:32
-
thanks. Could you recommend any books/tutorials that show examples of this? Nov 15, 2021 at 15:43
-
1@AfiaR.S. A flow chart depicts flow of control through the steps of a process - you can think of it as being a picture of an algorithm. While a state diagram can look superficially similar, conceptually, it does not depict "steps" or associated implementation details, but a set of abstract states (or "modes" or "dispositions" that have some meaning in the context of the problem you're trying to solve), and transitions between them - which have to be triggered (for the original notion predating UML, see this). Nov 15, 2021 at 18:50
-
@AfiaR.S. See also the Wikipedia article on FSMs. Framing the problem in terms of a FSM is different then thinking in terms of an algorithm you might implement in a general-purpose programming language; FSMs are a simpler, more constrained model of computation. Nov 15, 2021 at 18:53