On Sat, Mar 23, 2013 at 9:26 PM, Nabeel S. <[email protected]> wrote:
> Thanks for all the feedback guys, still trying to learn all the
> intricacies of the module system, and just the best patterns to use. I
> remember reading somewhere (I'll have to dig it up, though Crockford comes
> to mind), that the the "createLogger()" type of pattern is the preferred
> one.
>
I don't have empirical data to back this claim, but I strongly doubt that
this is preferred. As far as I'm concerned, a factory that does nothing but
wrap instantiation is a bug.
> I see it in a lot of libraries. Never really saw the point in that myself,
> seems more restrictive.
>
It's cruft.
>
> What I basically want to do is have the main exports be the instantiated
> object (of anything), but a static init() function. Just gotta play with
> all your suggestions and see how it works. Thanks guys!
>
Why do you need the init()? Why not...
// log.js
// just export an instance. done.
export = require("bunyan")();
// In some other file...
var log = require("log");
log.info("blah blah blah");
(this suggestion is untested)
Rick
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.