Why does this become a class diagram instead of a state diagram

0 votes
asked Apr 7, 2021 in Question / help by Mike

This creates a standard horizontal/vertical state change diagram:

@startuml
Hide Empty Description
Bob --> Alice : hello
Alice --> Bob : bye
@enduml

PlantUML diagram

If I want to add a description line to one of the states like this:

@startuml
Hide Empty Description
Bob --> Alice : hello
Bob : Test
Alice --> Bob : bye
@enduml

Why does it turn into a class diagram like this:

PlantUML diagram

How do I force this to be a state machine diagram and not a class diagram?

commented Apr 7, 2021 by The-Lu (64,340 points)

Hello M.

And if you want explicitly a state machine diagram, you can add 'state' keyword as:

@startuml
Hide Empty Description
Bob -> Alice : hello
state Bob : Test
Alice -> Bob : bye
@enduml

Regards,
Th.

commented Apr 7, 2021 by anonymous
Thank you very much, that worked perfectly.

I had tried:

State Bob --> Alice : Hello

But that generated an error.
commented Apr 7, 2021 by The-Lu (64,340 points)

Hello A.,

You can not mix definition and link...

@startuml
Hide Empty Description
state Bob
Bob -> Alice : hello
Bob : Test
Alice -> Bob : bye
@enduml

Regards,
Th.

1 Answer

0 votes
answered Apr 7, 2021 by Serge Wenger Work (15,620 points)

Hello,

Your first diagram is a sequence diagram, not a state diagram. I modify your sample with 2 proposals (click on drawing to show the code)

commented Apr 7, 2021 by SamuelRichards (100 points)
Thanks for the answer.
...