Categories: Software Development

grunt2gulp.js: JavaScript to CoffeeScript?

grunt2gulp-logoSo I don’t know if anyone is actively following the development of grunt2gulp.js but I decided to be a little more active in working on it. A week ago at work someone mentioned CoffeeScript and it’s a good time to check it out. I initially used it a long time ago when it first became available and I liked the result but it didn’t offer a huge improvement on the little JavaScript that we were writing at the time (under 200 lines of code).

However, grunt2gulp.js is starting to get…hairy. It’s about 400 lines (or more?) now and it’s time to split things up into separate files at the least.

I created a new branch called zesty-coffee and it’ll be using CoffeeScript. I’m using the npm preinstall script to compile the files into the bin/ script. Next step is making sure the conversion is complete and works correctly and after that I’m going to create a Gruntfile.js for linting the generated grunt2gulp.js file and for generating the JSDocs from it. After that we’ll have a good working example of a Gruntfile that can be converted to gulp within the repo so it’s easier to dog-food grunt2gulp.

The generated JavaScript from CoffeeScript is very nice and readable so debugging isn’t a chore. The list comprehensions in CoffeeScript do encourage a slightly different coding style and the lighter syntax for creating anonymous functions (a.k.a. blocks a.k.a. lambdas) encourages an almost functional style.

Check out the zesty-coffee branch on github.

Check out grunt2gulp on NPM.

Check out grunt2gulp on GitHub.

UPDATE: I manually converted the code from JavaScript to CoffeeScript. If you’re looking to automate your conversion from javascript to coffee, you can check out js2coffee.

Categories: AngularJS, Portfolio, Software Development, Web Dev Training

Deconstructing AngularJS Injector

I was reading through Coders at Work and realized that I haven’t done much code reading lately, other than reading through code samples in tutorials and articles. The interviews in the book suggested that code reviews and code reading are one of the most important things you can do as a professional programmer. This gave me the idea to write this article on the Angular injector.

I’ve been doing some stuff with AngularJS and one of the key ideas is dependency injection. Here’s a deconstruction of Angular injector.js which contains all the functions and classes for dependency injection.

Continue reading “Deconstructing AngularJS Injector”

Generating a Culture of Code Documentation

Generating a Culture of Code Documentation

This is from a presentation given at the Write the Docs conference,

Cutter’s experience is that SMEs fall into three categories in roughly equal proportion: eager to help, willing to help (with guidance in the form of templates and direction), and curmudgeons.

…You as a writer have knowledge that engineers need to help them write docs effectively, and when you share that knowledge you help them write more docs. Hold doc office hours where you’re available to help them with docs. Because some text is better than no text.

Curmudgeons will say “but code documents itself!” Cutter calls “bull”; code only tells what it does, not its intent. [NB: Intent is worthless if the code’s action doesn’t match it.] Even if you know what you wrote immediately after you wrote it, six months later you’ll have moved on and that’s when the documentation becomes critical.