These days I have been working on performance measurements of code sequences. In this context I noticed that the where-used list of the Orchestrator, Find Usages and Find Dependencies, does not resolve variablized method calls of getModule.
Variablized Modules, a Blind Spot of Find Usages/Dependencies
Here an example. At first I created an Action testStefan001, which delivers an everyday term:
At the second step I created an Action testStefan002, which calls this action on two different ways:
var ret = System.getModule("de.stschnell").testStefan001();
var module = System.getModule("de.stschnell");
for (var i = 0; i < 5; i++) {
ret += module.testStefan001();
}
ret += System.getModule("de.stschnell").testStefan001();
return ret;
|
The first way is the direct call and the second way is an indirect way via an object variable. The second way offers a better performantce, because the instantiation is done only once, before the loop. So far so good. Now let's take a look at the where-used list.
The calling module shows only the lines in which the call is made directly.
The called module also shows only the direct calls. The indirect method call, via a variablized module, is not considered.
Conclusion
As can be seen, the variabilization of the module has its advantages and disadvantages. When using the where-used list, we just have to be aware that the displayed lists do not have to be fully comprehensive. We may need to bring more code analysis techniques to use.