mritz_p
mritz_p

Reputation: 3118

What is the appropriate way to model API requests in Sequence Diagrams?

I am about to create a few sequence diagrams to model the interactions in a web API.

There is a repeating pattern of request/response calls that I am not sure how to model.

Say, I have an API call to request attributes from an API endpoint. Would it be appropriate to use the standard reply pattern like this? Is it good style to assign use multiple return value variables (encrypted_attributes, hashes)?

Standard Reply Pattern

Or should custom requests/responses be created like this, reflecting that both request_attributest and return_encrypted_attributes are done by units independent from each other?

Custom Request/Repsonse Pattern

Upvotes: 5

Views: 18496

Answers (1)

xmojmr
xmojmr

Reputation: 8145

Answers to what is appropriate or what is a good style can be only opinion based. I don't have a strong opinion on this subject, but I can see some decision points:

1) Sparx Systems Enterprise Architect can draw synchronous messages with "implicit return message" as shown here: http://www.sparxsystems.com/resources/uml2_tutorial/uml2_sequencediagram.html

Just 1 line (not 2 lines). Simpler diagram, easier to read.

2) Google: "uml sequence diagram best practices" returns several resources with pros/cons.

3) Usually when a decision like this is needed, following the path of least resistance (only 1st few miles paved..) also known as KISS principle is a good guide

Upvotes: 3

Related Questions