I'm reading Graig Larman's book Applying UML and Patterns and I was wondering if it's possible to represent an if statement in a SSD to exit the system. For example, let's say we have a search bar in a blog site, when the user clicks on search and there is no result, I want the system to return an error message "No results matching your criteria" and then to exit the system. How can I represent this in an System Sequence Diagram?
Generally speaking, a sequence diagram does not handle conditionals because the different outcomes of the conditional are two different sequences, and can be modeled as such. In your case, you have one sequence where the search returns the results, and one sequence where the search does not return any results, and if you consider both sequences to be of identical value, you make a sequence diagram for each.
This isn't really what a sequence diagram is for, though, it's for visualizing how entities in your system interact, especially when there is a chain of
A interacting with
B which interacts with
C and so on in order to produce a result.
In your case, I would recommend instead generalizing the sequence to a simple request and response, whether the response is an error or not makes no difference in terms of the interaction between search bar and back-end. That part can be modeled instead using an activity diagram, which are made specifically for modelling control flow.
If I'm understanding you correctly, the standard way I've seen this depicted is with a square box rotated 45 degrees (also referred to as a diamond, despite how wrong such a reference is). One line goes to one of the points to bring the flow into the "diamond", and two lines, labeled
no respectively, lead out. This can also be expanded to describe three state cases, but I've not seen any such diagrams have a solution for four or more state cases.
protected by gnat Mar 12 at 12:15
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?