Monday 13 March 2017

Optimise Node Module

So I regularly complete projects that contain user-stories similar to these:

  • As a user I can create bookings so that I can benefit from the services of the provider.
  • As a user I can see bookings with their status in a convenient list for record keeping purposes.
  • As a user, I can cancel a booking if it becomes inconvenient.
  • As a user, I can confirm the booking if it is beneficial.

I am trying to prepare a npm module that can easily provide this functionality to all future projects.

My question is, do I make the module have generic functions, i.e. like this:

exports.create = function() {
  //code removed to save space
};


exports.findOne = function() {
  //code removed to save space
};


exports.find = function() {
  //code removed to save space
};


exports.findOneAndUpdate = function() {
  //code removed to save space
};

Which together an be used to fulfil the tasks needed for these user stories.

Or do I actually make more user-story focused functions, i.e. like this:

exports.create = function() {
  //code removed to save space
};


exports.list = function() {
  //code removed to save space
};


exports.cancel = function() {
  //code removed to save space
};


exports.confirm = function() {
  //code removed to save space
};

Interested to hear your thoughts. Thanks.



via Jack Robson

No comments:

Post a Comment