Tuesday 15 December 2015

Questions about best practices in writing modules

Hi guys, I'm writing a custom module to upload my MongoDB dump into Dropbox at interval and I have some questions about best practices in writing modules:Module is basically a function with an 'options' argument. Some of the properties of that argument are required (like Dropbox app ID and secret), is there a way to check required properties and throw an Error if they are missing? Keep in mind that the module will be largely extended in the future.Is there a correct way to throw errors? Currently I'm using the Error class, is that the best practice?I will approach this project with TDD but I can't figure out what kind of tests I should perform. I think that I should write a test for every option, am I right?There is a general rule to organize the project structure? Should I split in files every single function, put them into some folder and include them?I know that probably there is already a module that do the exact thing I have to do, but the main objective of this project is improving my skills and build some best practices. Thank you all!

Submitted December 15, 2015 at 08:54PM by Lampad1na

No comments:

Post a Comment