5

I am drawing sequence diagram for large integration project where one system will initiate the REST call to another system and there is a proxy in middle which will pass through the request like

A->b->C

where b is a pass through system. I have shown 200 returned from C->b->A. I am wondering how do I depict when C returns 500 or there is an IOException and A needs to retry n no of times before it gives up.

Charu Khurana
  • 165
  • 1
  • 5
  • See also [uml-diagrams.org: UML Interaction Overview Diagrams Examples > Submit Comments to Pluck](http://www.uml-diagrams.org/interaction-overview-diagrams-examples.html#pluck-comments) – xmojmr Jul 22 '15 at 09:02

2 Answers2

9

One way is to use Fragments like this:

enter image description here

But honestly: code is much clearer for such purposes. Avoid using a graphical representation where a few lines of (pseudo) code can clarify what a 1000 pictures obfuscate. Once (in the 80s) I also though that programming graphically would be an advantage. But now I'm old an wise and know that this was wishful thinking. It's simply stupid ;-)

Regarding the IOException this heavily depends on runtime behavior. Usually this is a message sent from c which is not a return message but will produce a call stack in a. This can be placed in an alt Fragment.

  • Couple of questions here: 1. Is an `alt` fragment not for conditional things like if x>5 then this flow otherwise alternate flow. 2. I agree 500 is not a return message but could you show how to depict this in diagram – Charu Khurana Jul 22 '15 at 01:19
  • Exceptions tend to happen out of sequence. Leave them to use cases and keep them out of sequence diagrams where they add complexity but little information. – James Anderson Jul 22 '15 at 07:26
  • +1 it has always amused me that about the same time that software people were deciding graphical programming was the future, hardware people were deciding that graphical design didn't scale and they needed HDLs – jk. Jul 22 '15 at 08:26
  • I'm with @JamesAnderson. As said exception handling is very runtime specific which is why I idid not sketch it above. Activity diagrams have Interruptible Regions to show exception handling. SDs are not really suited for that purpose. Using alt is a "stutteringly" way to express exceptions. –  Jul 22 '15 at 09:08
4

I have seen colleges try to cover every single possible exception and error condition in every use case and sequence diagram. The result has always been late delivery, hours spent in review and in the end very little benefit to the project.

One way of thinking about it ala "Black Swan" by N. Taleb is that there are just too many possible disasters waiting to happen; the ant-virus software renders the machine unusable, the data centre could flood, admin forgot to pay the electricity bill, you company gets borked by a competitor etc. etc.

Another way to think about it is there are only thee exceptions.

  1. The service is unavailable.
  2. The service failed before your request could be processed.
  3. The service failed after your request was processed.

While cases 2 and 3 have very different outcomes its usually impossible to tell the difference without further manual investigation.

James Anderson
  • 18,049
  • 1
  • 42
  • 72
  • Yeah. People try to program gtaphically with SDs. In my young days I (and others) thought this would be the future of programming. It isn't. SDs should focus on single (complicated) aspects and try to highlight them. Any over-use will just lead to desaster... P.S. Oh, we discussed that already a couple of years ago ;-) –  Oct 18 '19 at 20:08