4 ms·
I wish I could downvote a comment that condescending. The Singleton Pattern is, as its name implies, a pattern. It's not a "good pattern", it's not an "anti pa
by joshguthrie 14y ago
I wish I could downvote a comment that condescending.
The Singleton Pattern is, as its name implies, a pattern. It's not a "good pattern", it's not an "anti pattern",... It is ONLY a pattern whose rightful use relies upon the developper.
Is a singleton justified in this case where the developper wants ONE connection object to be used across all his application? I don't see why not.
Would a non-singleton object that would be re-instancied upon each file/request/w/ever be better suited? I beg to differ.
But if your comment can teach us one thing, it's that for every pattern and every HN comment, the malice resides only between keyboard and chair.
- nbevans 14y agoIf my comment can teach you one thing it's that you need to learn IoC/DI, lifetime management and stop using the antipatten that is the singleton. It's a pattern that only makes sense on a hack day and nothing more. HN has a low brow audience if my comment has seriously earnt a -4 vote.