4 ms·
Necessary singletons are a sign that your language/library either embraces "everything is a class" so you have to make vacuous singleton classes to get full acc
by bcoates 14y ago
Necessary singletons are a sign that your language/library either embraces "everything is a class" so you have to make vacuous singleton classes to get full access to the language, or it is lacking a sufficiently powerful module system so you have to implement an ad-hoc one yourself using classes.
Unnecessary singletons are usually a sign that someone, somewhere designed a way too general system that allowed multiple instances of something, then nobody ever used that feature, then someone else came in and made things a bit saner by adding a singleton constraint, leaving vestigial object-ness and meaningless pointers being passed around everywhere.
In a perfect world with perfect programmers you'd never see one so the instinct that they smell bad is correct.
- masklinn 14y ago> Unnecessary singletons are usually a sign that someone, somewhere designed a way too general system that allowed multiple instances of something, then nobody ever used that feature, then someone else came in and made things a bit saner by adding a singleton constraint I fail to see how that makes anything saner.
- bcoates 14y agoIf your program has an unused and untested capability, killing it is a move in the right direction even if it makes your program less elegant. Bad behavior is worse than ugly design. Of course the right thing to do is to simplify the rest of the program to take advantage of the new assumption but maintenance programmers don't always have the luxury.