1

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
  • Consider two rooms, a door in between and a dog. Dog can't go through a closed door. Would two separate state diagrams of a door and a dog be of any use?
    – Basilevs
    Nov 15 '21 at 6:41
3

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.

6
  • 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?
    – Afia R. S.
    Nov 15 '21 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.
    – Ister
    Nov 15 '21 at 8:32
  • thanks. Could you recommend any books/tutorials that show examples of this?
    – Afia R. S.
    Nov 15 '21 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 '21 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 '21 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.