Readme, methods & Spikes


  1. Readme file.
  2. Methods
  3. Spikes


I didn’t do much last week (at least it felt like it), I fixed the two macbooks and I had to do small “hacking”, I discovered about daemons and launchd.plist in my research to fix the odd behavior I was having.

I found SleepWatcher by Bernhard Baer

SleepWatcher is a command line tool (daemon) that monitors sleep, wakeup and idleness of a Mac, It can be used to execute a Unix command when the Mac or the display of the Mac goes to sleep mode or wakes up, after a given time without user interaction.

I had a problem with the screen of the MacBook I am using and I couldn’t make it go to sleep, so I found the command pmset sleepnow that sends directly to sleep the MacBook and this was working, so with the SleepWatcher tool, I was able to trigger this command as soon as the screen was going to sleep.

So I don’t have a full working MacBook but from two broken MacBooks I was able to get one working, in terms of performance is working nice, the only thing is that the display sleep doesn’t work, but with this I fixed.

1. Readme file

AirCrewMentor took a look at the Readme file I had little improved and started to correct it, since it wasn’t really useful at all.

So here is the structure we are using on our Readme file:

  • Mortgage Calculator.
    • Installation
    • Usage
      • On Node.js
      • On the browser
    • Methods.
      • MortgageCalculator.getMaxMortgage
        • Options
      • MortgageCalculator.formatMoney
        • Number
        • Options
    • Contributor notes:
    • Notes:

AirCrewMentor when is going into a personal project, he uses the Readme as a guideline, he usually starts with it and then goes to code what he described.

James Shore uses a to-do list to go ahead with the project and with every commit deletes the task he has completed.

I think each method has its advantages, with AirCrewMentor’s method you keep focused on the main task, and you have the advantage that the documentation is going to be really solid since it is the guideline you used to commit the project. As a con I would say that it is harder to focus on smaller tasks.

With James method I think it is really easy to add new tasks and to focus only in small tasks, but then you’ll have to generate the Readme from scratch once the project is done, and it will require an effort to make it as solid as the one made with AirCrewMentor’s method.

I personally think AirCrewMentor’s is more useful but as my low level in coding it is really challenging. Of course I need more coding to get a valuable opinion on this.

With AirCrewMentor’s method we were defining the variables we were going to use and creating new ones that the methods should have. This way we encourage the readability of our code and give it more sense. So when a new user needs to use it, reading the code could be enough.

2. Methods

Today I learned a basic stuff that haunted me for some time but never had the time to look into it.

So I am coding every function into a separate file, well, not every function but the ones that are related or the ones that are going to be a method of our module. Always respecting the node.js way

But I really didn’t knew exactly why (totally), now I know a little more.

On our index page I created the following code:

module.exports = {
  formatMoney: require("./format_money.js")

So now, we can use the method mortgageCalculator.formatMoney(Number, options); in our code.

3. Spikes

So we created a spike to test that our method was working the way we wanted.

// this spike is going to validate the public interface
// described on the readme file.
var mortgageCalculator = require("../");
var options = {
  symbol: "€"
var result = mortgageCalculator.formatMoney(123456.9998, options);

So here we can see that we didn’t specify the location of our file, this is because node.js looks for its location into package.json specified into the "main": "lib/index.js"

Then we only have to call it with the following formula:

$ node spikes/name_of_the_file.js


  • Hands on coding!!
  • Get the code ready to publish on npm.
Thanks for your time @aircrewmentor, you are a true friend. (I already knew it, but know you are over the charts)

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s