Creating Software with Modern Diagramming Techniques: deactivation inside alt branches (page 31-32)

If I interpret this sequence diagram correctly, in case of invalid input, the Error message should end the activation of Sign Up Service. That is, just because a branch is the last one it shouldn’t be the one deactivating the participant, as activation doesn’t fall through branches (well, I think it shouldn’t) since they represent alternate flows of execution. In other words, if the valid input branch went first, it would end up activation of Sign Up Service and the error message would appear to be sent out of activation.

I imagine this is all due to a limitation of Mermaid, as I tried to deactivate SUS in the error message and got an error. I would report this to Mermaid but wanted to double check first, I also imagine someone else has already reported it.

The way I see it, the activation should end on the error message, and start again on the line dividing alt branches, to represent that on this branch, activation remains on since the GET /sign_up message.

This is an interesting one, and I can’t actually find any consensus on how it should render whether it be Mermaid or otherwise. I can see why Mermaid has done what it’s done, as ending the activation after the error and starting a new block in the alt would separate the initial activation from the alt case (the rectangle would be broken up).

I’m going to ponder on this one, as the alternative is put the start of the interaction in each alt branch, and then it works, but that feels wrong to me too, as I’d rather create a separate diagram at that point than create duplication.

Here’s the Mermaid, just to show what I mean in case it’s not obvious from my description:

    actor Browser
    participant Sign Up Service
    participant User Service
    participant Kafka
    Browser->>Sign Up Service: GET /sign_up
    activate Sign Up Service
    Sign Up Service-->>Browser: 200 OK (HTML page)
    deactivate Sign Up Service
    alt invalid input
        Browser->>+Sign Up Service: POST /sign_up
        Sign Up Service->>Sign Up Service: Validate input
        Sign Up Service-->>-Browser: Error
    else valid input  
        Browser->>+Sign Up Service: POST /sign_up
        Sign Up Service->>Sign Up Service: Validate input

        Sign Up Service->>+User Service: POST /users
        User Service--)Kafka: User Created Event Published
        User Service-->>-Sign Up Service: 201 Created (User)
        Sign Up Service-->>-Browser: 301 Redirect (Login page)

Yes, it was totally clear, and I agree that extracting the common messages is preferable to duplicating them, which is done only so that activation remains unbroken across branches.

I don’t think that “resuming” the activation at the start of each branch would be wrong, but it’s apparent that Mermaid’s authors don’t agree with me. I’ll raise that issue directly with them.

1 Like