seanmonstar

Jan 24 2012

Dec 5 2011

Nov 30 2011

Nov 21 2011

Past Month of Shipyard

Last month I got to start working on Shipyard almost full-time, as I need it to make Add-on Builder work by the end of the quarter. I’m not ready to call Shipyard 1.0 until I’m confident with the API for Models, Controllers, and Views. Models are largely done, Views need some work, and Controllers need a start. Besides that, though, what has happened to Shipyard in the past month?

Here follows a changelog-ish list.

  • Animations
    • A merge between MooTools’ Fx.Tween and Fx.Morph classes
  • Events
    • addListener returns a Listener object with attach and detach methods.
    • support for once
    • legacy API
      • official API for EventEmitters is addListener, removeListener, and emit
      • previous methods will soon log a DeprecationWarning, before being removed by 1.0
  • New utils
    • Logger
      • Makes the console more familiar for Python users
      • Doesn’t error if there is no console available
    • Cookie
      • Thanks to MooTools
    • Color
      • Thanks to MooTools
  • DOMEvent
    • Thanks to MooTools
  • Env
    • provides browser and platform
  • A briefer test runner
    • Only prints dots for successes, F for failures, and prints errors at the end

If commit lists are more your thing, you can look to GitHub. The next month should see event delegation, and more work on the View/template system.


Nov 8 2011

var that = this

I used to think say you should use that in the question “What variable should I name this for closures?” This was because self is already a variable that points to window. However, I’ve since revised my opinion on what is a good variable name in this case.

I now find that and self to be too vague.

Instead, I think the variable should be named after the Class that you are currently coding in. As always, it’s easier to explain with code:

var PackageController = new Class({

    doSomething: function() {
        var controller = this;

        someEl.addEvent('click', function(e) {
            controller.react();
        });
    }

});

The reason is because once you start delving a couple nested functions deep1, I find myself sometimes wondering if I bound that to the value I wanted. This way leaves little to wonder about. And since you read code far more than you write it, best to write the most readable code you can.


  1. I know, some of that can be solved by moving the functions to named methods on other objects, but you’d be lying if you said you never happened to have a function for a .forEach loop, and then another inside for an .addEvent, or something similar. 


Oct 19 2011

Sep 19 2011

Jun 29 2011

Page 1 of 8