IMHO the best approach is to take advantage of the object-oriented development environment that IRIS provide and have the common functions/methods in a single (or multiple) classes, possible abstract classes, and inherit them in the "main" class.
Class Community.perf.ClassMain Extends Community.perf.ClassAbs
{
ClassMethod Compare(NumCalls As%Integer)
{
Set Start=$zhDo..ClassCalls(NumCalls)
Set End=$zhWrite"Class calls: ",End-Start,!
}
ClassMethod ClassCalls(NumCalls As%Integer)
{
For i=1:1:NumCalls {
Setx=..Compute(NumCalls)
}
}
}
Class Community.perf.ClassAbs [ Abstract ]
{
ClassMethod Compute(Num As%Integer)
{
;Quit NumSet ret=Num
Quit ret
}
}
How about performance?
EPTEST>do##class(Community.perf.ClassMain).Compare(100000000)
Class calls: 31.675438In latest version of IRIS (and Cachè?) inherited members method code is no longer duplicated, so there is no difference then using separate classes but I think this approach is more modern, elegant and, depending on situations, MUCH more flexible,
- Log in to post comments