3 ms·
If your goal was to prove that some code unambiguously "sucks", then your example works against you. Because as I read this I see what may be a perfectly reason
by mcherm 16y ago
If your goal was to prove that some code unambiguously "sucks", then your example works against you. Because as I read this I see what may be a perfectly reasonable solution to common problem. (For future-proofing, the developer wanted to be sure most of the code shared a single INSTANCE rather than a CLASS with all-static methods. Then later, multiple instances could be used if needed. But since for now only one is used, she took the quickest and easiest approach to instantiating that single instance: no need for fancy factory classes when the instantiation will only be done once!)
- hnal943 16y agoThis is a failed attempt at a singleton pattern. The main problem here (there are MANY) is that there is no check to see if a Singleton already exists, meaning that the "Singleton" can be scrapped and replaced with a new object (most likely by accident) at any time. This code does in fact suck unambiguously.