18 March 2014

Last October, I published a repo and blog article about Flow-based Programming (FBP). After seeing Gulp and Browserify in action, I wanted to update the repo and see if I could increase my maintainability score of 135.58.

To my delight, all of my Grunt plugins were ported to Gulp, including docco! After some copy-pasting of configs, I rewired my package.json to point to gulpy versions of my formerly grunty packages. Then I set about refactoring the app without changing much code or functionality.

The main code bits I changed, as much to demonstrate Browserify as make the code better, was to use of Node’s native EventEmitter over the one I wrote. This eliminated an entire module from the application. I used util.inherits to give the .on() and .emit() methods to a Clock constructor. Now, other processes get invoked with app as their only parameter.

When I was done, I had 9 files. Testing these modules seems much simpler now. I may decide to add tests to further demonstrate test frameworks and the use of mocks for this style of application construction.

Ultimately, I was pleased by the results. This time the project scored an average 144.79 from js-complexity. Gaining nearly 10 points over the previous, already high, mark of 135 was not expected. The future of browser development looks very maintainable.


blog comments powered by Disqus