2

Sequence diagrams are used to model use case scenarios i.e., main success scenarios and alternate scenarios. That's what I understand from Craig Larman's book. I understand that it depends a lot on the practitioner. I mean a practitioner may decide not to model unimportant/obvious alternate scenarios etc.

Is there any accepted practice in the wild to draw a single sequence diagram for the whole system (having multiple use cases)? To me, it sounds a bit odd but I would like to explore if there, indeed, is something like this. It will be helpful if you could share references/links in support of this. I haven't found any yet!

1
  • 1
    What are you trying to get out of your exploration? Do you just want to know whether this can be done, or if there is any practical purpose for this?
    – Helena
    Nov 10, 2021 at 15:10

4 Answers 4

4

One common misconceptions of people who learn (or get taught about) UML diagrams is that a single diagram is supposed to explain the whole system. With the exception of extremely simple systems, that's usually not the case. Any system with realistic complexity would end up with diagrams which are so complicated that they would cause more confusion than they would resolve.

Theoretically it would be possible to do that, but it would take a tremendous amount of effort for very questionable benefit.

In practice, UML diagrams only show a small part of the system, and quite often in a simplified manner.

4

In short

Complexity is mastered by breaking complex matters down into simpler ones. Based on this principe, an UML model of a complex system is made of many simpler diagrams. So keep each of it as simple as possible but not more.

Golden modeling rule

Independently of UML, there is a limit to graphical visualisation: any diagram with more than 6-7 elements will appear difficult to understand to the average reader. Keep your diagrams below this limit.

Urban legend? No! Experiments on short term memory by AI pioneer Herbert Simon proved in the 70s this limitation of the human brain. Modeling experts can easily read more complex diagrams, but only because their experience trained them to cluster items, and with this trick they can go up to 6-7 clusters.

Still not convinced?

A sequence diagram only show one specific scenario under the viewpoint of interactions (message exchanges) between objects/parts inside the system.

For alternative scenarios in the same diagram, combined fragments are needed. Your diagram will grow very big, have nested messages, and might quickly become unreadable. I let you extrapolate what might happen if you'd add all the scenarios of all the use-cases, with all the objects...

Last but not least, interactions are not always the best choice to explain what happens. Activity diagrams or state diagrams are very interesting alternatives in many situations.

1
  • 1
    Just my two cents, As for growing big and decomposing into smaller bits, REF becomes the critical combined fragment for a sequence diagram. Still I keep to my words, modelling entire system on one sd is a poor idea and we seem to agree on that point.
    – Ister
    Nov 11, 2021 at 19:47
3

Sequence diagrams can be used to model use case scenarios, but they can also be used at other levels of detail, for example to show an interaction scenario of multiple classes in a detailed design.

As the vertical axis of a sequence diagram depicts time, sequence diagrams are not suitable to show multiple, independent scenarios in a single diagram. And that becomes even stronger if the scenarios can be executed in parallel.

In practice, it will just be impossible to draw a single sequence diagram that accurately depicts the multiple use cases of an entire system, while still being readable and understandable. Even with a single use case that has multiple alternate and/or error scenarios it can be a real challenge to capture them all in a single readable sequence diagram.

1

I cannot imagine how a single sequence diagram could work. It would be most probably less readable than the code itself, though maybe (just maybe) it's doable. Yet, doesn't bring a value so no, don't expect to have such standard.

However, there is one diagram you may consider, assuming you want to stay on a high enough level - and that is the interaction overview diagram. It will work only for a system with relatively few function though (as a single diagram of course, if you split it into smaller chunks you may be successful even for large-scale systems).

The interaction overview diagram kind of combines activity diagram with a sequence diagram. You can think of it as a large activity diagram, where for some activities you use actual sequence diagrams to depict those.

I need to warn you though - even relatively simple system produces extensive interaction overview diagram. You really need to stay focused and draw a fine line how detailed the diagram should be to achieve expected results.

Yet, I attempted it once. I didn't complete it but it had at least a chance to succeed so you may want to give it a try as well.

In case you wanted more details, you may take a look here

3
  • Interesting. I could not really imagine either. In fact, the typical way is to describe a use-case with an activity diagram. The interactions are then only specific interactions between involved classes in the activity. What I did not fully get with the interaction overview diagram, is what is the benefit of mixing general activities with specific interactions in one and the same diagram? And is this standard UML?
    – Christophe
    Nov 10, 2021 at 21:14
  • 1
    Yes, it is standard UML. I've added to the answer a link to respective uml-diagrams.org page. I must say I didn't use that diagram ever before (12 years as a BA now, using UML from since I've started) but I wanted to do pretty much the same thing that OP asked and after attempts with sd it seemed to be the only more or less reasonable solution. I fully agree with how it's done typically, but I believe it's good to know other available options even if you will use them once in a decade ;-)
    – Ister
    Nov 11, 2021 at 11:04
  • As for the benefits of combining activities and sd in one diagram - the flow is easier to read in the ad version with details about interactions being kept in sd version. Yet let me repeat myself - it's not something that you will use everyday. And even after giving it a try I am not sure if it really is that usable - the resulting diagram either is super small and gives little to no information and as a result value or is just humongous in terms of size.
    – Ister
    Nov 11, 2021 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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