Consider the following java classes:
public class GenericActionService {
public void runAction(int actionNo) {
.... (some stuff)
runActionCode(actionNo);
.... (some more stuff)
}
protected void runActionCode(int actionNo) {
switch (actionNo) {
case 100:
doSomeGenericAction();
break;
....
default:
throw new IllegalArgumentException("Invalid Action!");
}
}
}
And inherited sub-class:
public class SpecificActionService extends GenericActionService {
protected void runActionCode(int actionNo) {
switch (actionNo) {
case 1000:
doSomeSpecificAction();
break;
....
default:
super.runActionCode(actionNo);
break;
}
}
}
Now I'm not concerned about whether this is particularly good design or not, and these classes are highly fictional.
What I would like to know is, how do you represent this design with some sort of diagram? Can this be represented using a UML Sequence diagram? If not, what type of diagram should be used?
In particular, I'd like to diagram the flow/sequence when something calls the runAction()
method on an instance of SpecificActionService
.
For example, consider the flow of execution when runAction(1000)
is called on SpecificActionService
. I would want the diagram to show the following:
- Calls
SpecificActionService.runAction(1000)
- Which runs some code in
GenericActionService.runAction()
- Before it calls
SpecificActionService.runActionCode(1000)
- Which calls
GenericActionService.runActionCode(1000)
- Which performs the action
- Before returning to
SpecificActionService.runActionCode(1000)
- Which returns to
GenericActionService.runAction(1000)
- Where more code is run before it returns to the original caller
The problem is some people consider this to be "modern spaghetti code", especially managers who don't seem to 'get it' when it comes to this kind of inheritence structure, so I'm wanting to document this flow so they understand.
Extra points to those who draw a pretty picture for me. :-)