How to represent calls within same class using UML-Sequence diagram

Ashay Batwal picture Ashay Batwal · Feb 11, 2013 · Viewed 38.5k times · Source

I am trying to create UML sequence diagram for a particular process in our application.

The problem is that most of the business logic is in one class and when I try to map it in sequence diagrams, I am getting multiple calls to the same objects in the sequence diagram.

What I need is a representation similar to a stacktrace in UML sequence diagram. Is it possible using sequence diagram or is some other diagram a better way for representing calls within the same class? Please advise.

Answer

sfinnie picture sfinnie · Feb 11, 2013

A few suggestions:

  1. You can show successive methods on a sequence diagram using self calls. See Figure 1 here for an example (self calls are the circular invocations on the same lifeline).
  2. As an alternative you might consider an Activity Diagram. Possibly better suited for illustrating order of methods.
  3. Refactor the code. Lots of logic in a single class is usually a bad smell. Assuming you have the scope, refactoring might be a good idea.

hth.