javascript

(Note: if you aren’t using jasmine and jasmine-jquery to test your javascript go take care of that) Suppose we’re working on a sliding tile game, and we want to log the moves a player has made. We could create a Logger object to collect the moves, and use a callback in the Game method to update the logger. One of the simplest ways to implement a callback is with standalone function: Game.after_move = function() { for (var i = 0; i < this.
2012-12-17
3 min read
My friend recently asked me “Do you have any advice for encapsulating javascript or how to break an application into files/namespaces? Most of what I see online for javascript is hacky and not about designing for maintainability.” Turns out I do! First of all, you need jasmine and jasmine-jquery. I always thought TDD was a nice but impractical idea until I had an environment with fast tests. At Contour I had 130 jasmine tests (averaging maybe 3 assertions each) running in 500ms.
2012-03-24
4 min read