Re:MongoDB singleton connection in Node.Js
by nbevans on Friday April 05, 2013 @08:24AM
(#5497903)
People are still writing Singleton pattern code in 2013? Wow.
[ Parent
| on HN ]
Re:MongoDB singleton connection in Node.Js
by joshguthrie on Friday April 05, 2013 @08:46AM
(#5498020)
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.
If 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.
Re:MongoDB singleton connection in Node.Js
by outside1234 on Friday April 05, 2013 @09:08AM
(#5498140)
People still don't understand that node.js is single threaded in 2013? Wow.