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:
SpecificActionService.runAction(1000) GenericActionService.runAction()SpecificActionService.runActionCode(1000)GenericActionService.runActionCode(1000)SpecificActionService.runActionCode(1000)GenericActionService.runAction(1000)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. :-)
In particular, I'd like to diagram the flow/sequence
So I would use a sequence diagram. This can show how the Objects work together. It did not show you the inheritance structure and how to write the classes but for this you can also add a Class Diagram later.
And here a fancy simple image how this could look:

And the plantuml source code if this is not good enough and you want to experiment with this :).
otherObject->SpecificActionService:runActionCode(1000)
SpecificActionService->SpecificActionService:doSomeSpecificAction()
otherObject->SpecificActionService:runActionCode(100)
SpecificActionService->GenericActionService :runActionCode(100)
GenericActionService->GenericActionService:doSomeGenericAction()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With