walk with params... the whole way?
hello.
consider the following:
abstractpublicclass Test{
void doSomething()
void doSomething(double x, Object o)
}
with doSomething is "equal" except it for SOME Tests/derivates need args, for others not...
there is also some intercompatibilty eg, its okay to call doSemoething(DEFAULT_X, null) if needed...
now a smart design is maybe:
interface SomethingWithParamDoer{
void doSomething(double x, Object o);
};
abstractpublicclass Test{
void doSomething(){
doSomething(DEFAULT_X,null);
}
void doSomething(double x, Object o){
doSomething();
}
publicstaticvoid main(String[] args){
doWithManyManyTests
if (testinstanceof SomethingWithParamDoer)
test.doSomething(x, o);
else
test.doSomething();
}
}
although its horrible because no one guarantees for overloading of one of the doSomething so happy deadlocking...
on the other hand, its much cleaner to only use the parameterized version of
doSomething and fill with defaults if not needed. but maybe that hides which one needs params, and which not so the caller is uncertain about the situations params are useful or not.
also the empty params would spoil cpu cycles?
-perf. is an issue here.
the above example would get far more complicated at my app as i maybe use two or three params, that are abitrary useful, independent of each other.
its that... most calls are obviuos , eg. use much real non-default params but some special cases need default fallback, and severall objects would not have any use to some of the params, but "to the most"...
so what would you do?
thanks & greets
Paul

