0 Comments

Have you ever noticed that furniture makers always make computer desks with those closed off little cubby holes for the tower? It’s about time someone told them computers need ventilation to work properly. I’ve seen countless computers overheat and die an untimely death due to this lack of understanding of simple common sense.

Computers have fans in them for a reason: air flow. They take cool air in and expel hot air, all the while keeping the internal case at a constant temperature, in theory. Most of the time though they run hot if they’re more than the little Wally-world special.

So, furniture companies, please remember to leave plenty of breathing room and exhaust ports for computers in your desks and nooks.

0 Comments

Just a quick note on jQuery Deferred objects…

   1: var goGetSomeHtml = function() {
   2:     var deferred = $.Deferred();
   3:     $.ajax({
   4:         url: “some.htm”
   5:     }).done(function(data) {
   6:         deferred.resolve(data);
   7:     }).fail(function(jqXHR, textStatus) {
   8:         deferred.reject({ xhr:jqXHR, textStatus: textStatus });
   9:     });
  10:     return deferred.promise();
  11: };

They’re basically a callback wrapper. This example is a bit redundant since jQuery $.ajax returns a Deferred already, but you get the idea. You can use this for anything that requires a callback. It provides a pattern that pushes the callback function into user code in a way that is standardized. The resolve and reject functions on deferred pass their parameters into the callbacks in the done/fail functions.

This lets you pass the deferred promise around (a promise is just a deferred with the resolve/reject removed from its interface). A bit cleaner functional approach that removes the need for you to worry about call/apply syntax and context.

The above can then be used like this:

   1: $.when(
   2:     goGetSomeHtml()
   3: ).done(function(data) {
   4:     //do success callback stuff here...
   5: }).fail(function(state) {
   6:     //use state.xhr or state.textStatus to handle the error somehow.
   7: }

Enjoy. Smile

0 Comments

For a while now I’ve been kicking around the idea of a jQuery script loader. There are several that take the problem halfway there, but usually they are implemented in a way that makes them harder to use than they need to be, or they are lacking certain key features.

Here is what I think the loader would need to be capable of in order to be done right. It should:

  • be AMD compliant
  • handle nested dependencies
  • handle composite/combined scripts (scripts that contain other modules that could be loaded separately)
  • allow for a way to check if a script is loaded other than its own internal index (like !!window.jQuery)
  • allow dependencies and composite modules to be defined on the script itself (optionally support a self-executing wrapper)
  • not allow itself to be stomped on if it is loaded multiple times via script tag or other means

Ideally this should be integrated into jQuery itself. Boris Moore has developed a loader that does some of these things called jsDefer but it has some issues at present. Its composite script support does not really function as the documentation would lead you to believe and the script definition process for wrapped scripts is lacking a way to name nested combined scripts easily (or it just has a bug).

There is a loader in the Ajax Control Toolkit that elegantly handled most of these issues, but few knew about it and less used it. However, it is not AMD compliant and has been deprecated and fallen out of favor in most circles due to its tight coupling the the toolkit and the rise of ASP.NET MVC.

So, it needs to be built into jQuery. It makes sense to do so because jQuery has over half the functionality needed by the loader already baked in. It shouldn’t really be a plugin because you should have one consistent way of loading all your plugins. But if it is to be baked into jQuery itself, jQuery needs some modifications. At the moment jQuery does not check for itself when it loads and there are many versions floating around in the wild. When building modular solutions there is a need to load jQuery multiple times on a single page and you cannot guarantee that widget A uses the same version as widget B. So to overcome this we need changes.

jQuery should:

  • defined in a feature manifest for each version, or
  • check for its own existence, and if found
  • check for its version, or
  • check for prior existence of each feature, and
  • override the feature if it is an older version, while
  • not stomping on itself, thus preventing plugins from being trashed (extend, don’t assign)

Anyway, these are just my ideas around a built in script loader and how jQuery needs to change to support this type of scenario, which is becoming more commonplace.

0 Comments

I went to the SIC today and it started out a little sideways. I left the hotel and got a cab to the convention center. Only it wasn’t in the main convention center, that was a legal conference for attorneys. SIC was setup across the street on the opposite corner. When I actually showed up, I hadn’t gone to the pre-party the night before, so I got in the registration line. Problem was they didn’t do the demographics on how many people had A-H or whatever it was as their last name’s first letter. Because of this oversight they managed to create a line that filled the entire lobby for quite a while. Now correct me if I’m wrong, but wouldn’t the organizers, who should be in the marketing field, be the first ones to know that you have to split your registration lines by the number of people and not just by the letters?

After that it went downhill. The first talk I attended was Jeff Barr in Cloud Computing: How We Got Here, Where We Are, and Where We Are Heading. I expected a quick gloss over the past and present since we’re mostly all in the field and we ALREADY KNOW THIS STUFF. Several people left well before the talk concluded for just that reason. The entire day was riddled with this kind of thing from talk to talk. Several of the other talks were just agencies bragging about their portfolios. Nothing to see here, move along… People in the field (marketing, PM, designers, etc.) commented to me about this and how they expected more. I can understand if I find it lacking, being that I’m a developer and I am not the target audience for this, but come on. If even they are talking about it, there is something wrong here.

Anyway, my $.02 is next year, fix the registration line fiasco with some common sense. And get speakers that don’t want to brag, but want to share tips, tricks, ideas, and real meaningful information. Otherwise this is just an excuse to take two days off work and party.