Geek Smithology

January 31, 2006

After you zoquo, do you ushnu?

Filed under: Craft of Dev by Nathan @ 6:10 pm

One of the most crippling forms of design paralysis I’ve witnessed is something I call library fever: when a team cannot write a single null check or status verification without a static method tucked away in some *Util class. Similar to architecture astronauts, these guys and gals weave intricate designs for core libraries that promise to eliminate all ad-hoc conditionals. What these people fail to produce is working software. In this post, The Rontologist reminds all you coding hitch hikers around the galaxy to always remember your towel. Sound advice, but let’s remember what those towels are for…

The best custom libraries don’t come from deciding up front that you want to check the status of a variable, they come from discovering repeated patterns in your codebase where the expressivity of recasting those patterns as well-named methods outweighs the dependency that is introduced. In doing so, you must consider the semantics, not just the mechanics. For example, Ron suggests replacing this code[1]:

if (request.getParameter(“name”) != null && request.getParameter(“name”).length > 0) {
     // code

With this code:

if (!WebUtil.isEmpty(request.getParameter(“name”)) {
     // code

This is a perfectly sound mechanical implementation refactoring with which most developers would have no qualms. Yet if we delve deeper beyond the logic into the intention we can make it clearer (and after a few methods, it will border on humane, but won’t get insane.) If the purpose is checking for a parameter in the request, why not call a spade a spade?

if (WebUtil.containsParameter(request, "name")) {
    // code

In addition to making the intent clear, this replaces a negated conditional with a bare one that is more readily read. Suppose we wanted to look for an attribute instead. Any isEmpty() method seems silly now — what would we pass it, an Object? So now the code would be:

if (null != request.getAttribute("name")) {
    // code

And now two actions with similar intention have different local idioms. Following the previous pattern, we simply add a method:

if (WebUtil.containsAttribute(request, "name")) {
    // code

Same signature, similar method name, cleaner code. The coup de grace (and the humanity) comes when you want to check for the presence of a string in the request and you don’t care where it comes from: perhaps the information may be parameter for a direct request but in an attribute for a forward. Rather than this:

if (!WebUtil.isEmpty(request.getParameter("name")) && null != request.getAttribute("name")) {
    // code

We have this:

if (WebUtil.contains(request, "name")) {
    // code

If you thought it were appropriate, you could even wrap the request into a custom version and simplify the code to request.contains(“name”). The intention doesn’t get much clearer than that.

The point is not that the DRY principle is wrong, but that you can’t know for sure the best single, unambiguous, authouritative representation for any single datum within a larger system until you have working code that you can refactor. Call it tracer bullets, iterative development, or agile, it all boils down to the same basic principles: make your code right, make your code clean, make your code fast. Necessarily in that order.

There’s no point in getting DRY if you didn’t get wet…

[1] I’m not having a go at the Rontologist because I know he’s just making up code for an example (although it does look suspiciously like code I would’ve written not too long ago!), but I do want to point out the dangers of micro-refactoring.

January 27, 2006

The Hitchhiker’s Guide to DHTML

Filed under: Craft of Dev by Nathan @ 7:03 pm

I’m doing a lot of (gag) HTML layout for my current task, and as I was browsing through O’Reilly’s[1] Dynamic HTML: The Definitive Reference by Danny Goodman I was tickled pink (manly pink) by how funny this is for a reference book. Some favorites:

On <center>:

<center>Don’t do this</center>

For <comment>:

Further details are omitted here to reduce the incentive to use the element.

And my favorite, what Mr. Goodman has to say about the (rightfully) maligned <blink>:

All content of the element flashes on and off uncontrollably in a distracting manner…Please don’t use this tag. I beg you.

In addition to entertainment value, this book provides the single best reference for HTML/CSS/DOM I’ve seen and is an excellent example of why true geeks love O’Reilly. If you’re doing significant front end web development, you need this book.

[1] Nothing like typing a word with two apostrophes feel like the regular laws of syntax and grammar no longer apply, eh? I’m sure there are typographical uber-nerds that will explain to me that one of the characters is not a true apostrope (whatever that means) but they’re both actually single quotes so I’ve pre-emptively taken the wind out of those sails.

January 23, 2006

Review – Bjorn Again with Nearly Neil

Filed under: Sound by Nathan @ 9:31 pm

The travelling extravaganza known as The 70′s Show[1] descended upon Jack Singer Concert Hall on Saturday, January twenty-first in the year of our Lord two thousand and six and it was the end of the world as we know it. As a card carrying Sex Pistols fan, I’m not sure what hurts more to admit: that I went to a concert featuring Neil Diamond and ABBA impersonators, or that I enjoyed myself. Thoroughly. What the hell, my music tastes are so out there that anybody who is surprised by either declaration doesn’t know me as well as they think they do. But, enough about me…

As we entered the Performing Arts Centre, my wife was surprised to find that at 31 we were actually bring the average age of the crowd down by some statistically insignificant number. She tried to convince herself that they were there for a different show, but sure enough, as we took our seats in the nosebleeds we were king and queen of all we surveyed – a sea of white hair. I had to remind her that a) my parents like ABBA and b) my grandparents like Neil Diamond. Aside from a tendency to not get up and dance and to look at me like I was insane when I did, they basically stayed out of the way. Sometimes that’s the best you can ask from the fogies at a concert.

This whole adventure begain as a brave effort to take a bullet for my wife (apparently always going to movies that she doesn’t really want to see isn’t her idea of fun. Who knew?) But when Nearly Neil, resplendent in blue sequins, came out and started belting out America I was into it.[2] The guy had impressive range and was a lot of fun. He ran through a veritable cornucopia of hits: Holly Holy, Kentucky Woman, Girl You’ll Be A Woman Soon, I’m a Believer, Forever in Blue Jeans, and Cracklin’ Rosie. Unfortunately for all involved he didn’t do Shilo or, tragically, Song Sung Blue[3].

This was followed by the main event – ABBA wannabes Bjorn Again. Aside from the music, which is the pop-disco you either love or hate but have a definite opinion about, the show was an eclectic mix of humour, audience participation, and KISS. Yes, KISS. About halfway through the set, the ladies went off for a costume change and the dudes threw down a monster cover of I Wanna Rock ‘n’ Roll All Night that was arguably the high point of the show. They visited most of the songs I know and quite a few I didn’t during a hypnotic 80 minute set. When they said goodnight without singing their super-hits, my wife expressed faux concern.

Of course, everybody knew that they were saving that for the encore, predictably consisting of Take A Chance On Me followed by Dancing Queen[4][5]. There was a nice rap interlude during the former that was both comic relief and a chance to exercise my (in)famous b-boy moves. I thought that was it, but Nearly Neil came out once more to join Bjorn Again, forming an impromptu supergroup to perform a rousing rendition of Sweet Caroline. It’s a little embarrassing, but I was so roused that I had to throw up the horns during the last chorus.

What can I say, Nearly Neil is fuckin’ metal.

four and a half star

[1] I imagine placing a definite article in place of the more familiar conjuntion used by a certain TV show was done to prevent litigation. Or I’m cynical — one of the two.
[2] Guilty Pleasure Moment: I like Neil Diamond. Hey, it’s better then that time you liked Boomtang Boys (or, god forbid, Aqua) “back in school.”
[3] You know…even I’m not sure if I’m joking.
[4] Is it just me or is the bpm for Dancing Queen far to slow for any self-respecting dancing queen to strut the proverbial “stuff”?
[5] Nathan’s top five encores, in descending order: Bourbon Tabernacle Choir tugging at the heart strings with Simple, REM playing around with Permanent Vacation, Erica Raum destroying Paganini’s Caprice No. 5, Jack Semple channeling Hendrix through Fire, and Thomas Manshardt throwing every last ounce of strength into Homage a Liapunov. I’m serious, it was his third encore (the crowd would not let him leave) and we thought he was dead when it ended.

January 16, 2006

#@$%&! WordPress Upgrade…

Filed under: Announce,Craft of Dev by Nathan @ 9:14 pm

If you read this blog through certain aggregators (Bloglines being one of them) you will have noticed the feed was down for a while before disappearing altogether (nice!) It’s because I updated to WordPress 2.0 (not worth the hassle, frankly) and certain aggregators (Bloglines being one of them) started getting some 404 action on the feeds.

Unfortunately, I found out a little too late, but c’est la vie, n’est pas? To resubscribe (or subscribe in the first place), please use the new official feed URL:

NOTE: For fellow WordPress bloggers who are upgrading to 2.0 and don’t want to turf their existing feeds, I found that you can redirect the old scripts to the new paths using Apache’s Rewrite module. Just add the following lines to your .htaccess file:

RewriteEngine On
RewriteRule ^/wp-rss2.php$ [L]
RewriteRule ^/wp-rss.php$ [L]
RewriteRule ^/wp-atom.php$ [L]

OR, you could just create a Feedburner account, use Steve Smith’s most excellent plugin to redirect your traffic and be done with the whole mess (not to mention get some nice tracking features in the deal)

Apologies to any readers I lost because of this – hopefully you find your way back. To everyone else: the Magical Mystery Tour continues unabated!

January 13, 2006

MP3otW – Ray of Light by Sigue Sigue Sputnik

Filed under: MP3 of the Week by Nathan @ 9:59 am

I remember the first time I heard Sigue Sigue Sputnik back in the day – so much different than the usual suspects (typical mid to late 80′s skate rawk like Suicidal Tendencies, Dead Milkmen, Butthole Surfers, and pre-sellout Red Hot Chili Peppers). I also remember the first time I heard Ray of Light and thinking “WTF? Madonna doesn’t suck?!?”

So if you can, why not combine the two? Maybe it’s not original to post a Madonna cover tune, but when it’s this good can you blame me?

January 8, 2006

Review – King Kong

Filed under: Sight by Nathan @ 1:17 am

When I read that Peter Jackson was remaking the most iconic monster movie in the history of the cinema one word came to mind: hubris. He did what no Harry Potter movie can ever do when he won the Oscar for Return of the King, but King Kong was already remade in 1976. What is the point? The short answer is “because he could.” The long answer is slightly more complicated.

New York, 1933. The depression is in full swing, and vaudeville actress Ann Darrow (Naomi Watts) has been thrown out into the street. Enter Carl Denham (Jack Black), a Z-grade movie director with a mysterious map filming a movie on Skull Island. In a sly reference to the original film “Faye” isn’t available, so Carl needs to find an actress that will fit her costumes. Luckily, Ann fits the bill and agrees to appear in Denham’s film when she discovers that the great Jack Driscoll (Adrien Brody) is the writer.

Once the crew disembarks on the island things go wrong quick as Ann is kidnapped by natives and sacrificed to their god. Having fallen for her during the journey, Jack embarks on the great adventure that is the middle third of the film to find her. And what an adventure it is – dinosaur stampedes, giant ape vs. T-Rex battles, man vs. giant insect battles, and a veritable cornucopia of buckled swash. When the dust finally settles, the crew has captured the great Kong and taken him back to the big apple.

At his debut, it doesn’t take long for Kong to break free of his chains and go on a rampage looking for Ann. When he finds his lady, they go for a happy-go-lucky romp on a frozen pond before the military arrives. The proverbial climbing of the Empire State Building follows, but I would not dream of spoiling the ending.

As special effects extravaganzas go, this is the new pinnacle. The Skull Island fauna are a treat, and the recreation of 1933 New York is convincing. Action is not the sole purpose for which the CG is employed, however. The expressiveness of Kong is astounding, resulting in a far more nuanced and fully-realized character than any of the talking animals in Chronicles of Narnia. It is this nuance that makes the central relationship of Beauty and the Beast believable and even poignant. Shortly after meeting, Ann does her vaudeville routine, and Kong laughs so hard he decides not to eat her. The final moments atop the skyscraper will draw a tear from sensitive folks.

But it is not a perfect picture. The beginning runs a little longer than it needs to, and there are scenes on the island that drag more than they flow. Yet, these thoughts only come to mind after the movie is over – it does not feel too long in the theatre. Watts is luminous if adequate, Brody is an unlikely action star, and Kyle Chandler puts in a fun turn as egotistical screen star Bruce Baxter. There have been grumblings that Jack Black is wrong for the part, but I enjoyed his performance. Yes, he plays Carl Denham as Jack Black, but that is the point of casting him.

Jackson is a director at the top of his form, and it is obvious that he is destined for even greater things. Not only has he proven that there was more to say about the Kong story, but he as shown how good a blockbuster can be. One can only hope that Hollywood gets the memo: a movie can be thrilling without dumbing it down to Godzilla levels. King Kong is an excellent film and has to be experienced to be believed.

four star

January 2, 2006


Filed under: Sound by Nathan @ 2:18 am

You know, sometimes when you hit that little shuffle button in your iTunes/iPod it comes up with a couple o’ songs that just make you go “whoa.” Obviously this just happened, otherwise I wouldn’t be bothering to write this post. Anyway, check this out:

Song 1: The Wreck of the Edmund Fitzgerald – Gordon Lightfoot
Song 2: Land Ho! – The Doors

Whoa. Not exactly life changing, but cause for a short respite for some philisophical rumination. Still on holidays, still not missing work. Hope everyone had a fun (and safe) New Year.

Powered by WordPress