puzzlecracker wrote:
Why all static, rather than singleton?
I want users to either use this class without any initialization:
UtilityClass.oper1()
Can't you do something like:
class MyUtils {
private static boolean alreadyDecidedWhatToDoAboutInitialization;
private static void init() {
if (!alreadyDecidedWhatToDoAboutInitialization) {
alreadyDecidedWhatToDoAboutInitialization = true;
computePlanForSolvingWorldEnergyProblems(OtherClass.something);
saveTheWhales();
//...
}
}
public Type1 DoStuff1(Type2 t) {
init();
BlaBlah(t);
//more
}
public Type3 DoStuff1(Type3 t) {
init();
BlaBlahBlah(t);
//more
}
}
It's fairly standard. .. the call to init() when the if-test eval to
false takes almost no time.
BTW, it is not a "static class" -- just a class without any instance
members / methods. A static class is a class nested inside another
class, and declared static.
Soren
That is what I have. I was wondering whether another, more elegent, but