On Tue, Aug 14, 2012 at 10:40 AM, Mark Volkmann <[email protected]> wrote: > I know there are many opinions on the best way to organize functions into > Node modules. > I'd like to throw out an example and see what people think. > Suppose you are writing a module that performs basic statistics. > There are three functions that compute the mean, median and mode of values > in an array. > Here are some ways I think people might organize these. > > 1) Create a separate module for each function. > 2) Create one module that only exports the mean function, viewing it as the > most commonly used of the three. > Add the median and mode functions as properties of the mean function so > they can be accessed from it. > 3) Create one module that exports all three functions. > > Which of these would you prefer? Is there another option I haven't > described?
For a module like this, I would go for option 3. They are too tiny to be their own module each. Option 2 puts too much focus on the mean function. It's not fundamentally different from the others. Being simply used more often doesn't make it a different kind of thing. > -- > R. Mark Volkmann > Object Computing, Inc. > > -- > 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 -- 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
