Archive for February, 2009

Phat Birthday Loot Accruement

Monday, February 23rd, 2009

In the aftermath of my 24th birthday, I can proudly announce the addition of two new items into my bookshelf, one new to me, and one a familiar friend: Consider Phlebas, by Iain M. Banks, and the classic Dune, by Frank Herbert.

I had previously read another of Iain Banks’ science fiction novels, Against A Dark Background. Initially, I had mixed feelings about the book, since I recall being vaguely confused about what the whole book was meandering towards. Once it got there, though, I appreciated both the setting and the story a good deal more. For some reason, I’d picked out Consider Phlebas as the next Banks novel I’d like to read, a fact my girlfriend pounced on when trying to figure out what to get for the momentous occasion of the commencement of the next cycle in my aging process. So far, I’ve gotten up to page 142 of the 467 between the covers, and I like what I’ve been reading so far. I actually haven’t realised how starved I’ve been for some new science fiction material. Once I’ve finished Consider Phlebas, I fully intend on re-reading it. Come on, every book needs at least one re-read.

Regarding Dune: man, I love that book. It’s probably one of my all-time favourite novels. Ever. Which is why it’s heartbreaking to see it given such a despicable front cover. For crying out loud, the word DUNE consists of several tiny little five-pointed stars clustered together. Really now. It’s a hard science fiction novel, not My Little Fucking Pony.

In other news, the Wordpress gallery tag thingy isn’t that great, but flowing in all of the covers would probably have looked even worse.

Ugly Code And Why It’s Good

Tuesday, February 17th, 2009

While helping a colleague with a defect regarding things that should not happen but were and caused the whole tower of sticks to come tumbling down, I noticed a block of code that follows more or less the gist of the pseudo-sample below:

if(lots of conditions)
{
    doSomeStringCopies();
    if(a certain condition)
        doSomething();
        doSomethingElse();
    doFinalStringCopies();
}

Bear in mind that the consistency of indentation of the actual code was nowhere as nice as above.

Notice the problem? doSomethingElse() will be called irrespective of the secondary condition, resulting in bad things happening because a certain field does not contain a valid value for the doing of something else, but is entirely valid in terms of the business rule.

This is why you always surround your compound code structures with braces: because you never know when someone’s going to slide a “fix” into your code and neglects to add the braces. Several people (who have obviously never been burnt by this problem, and if they have, they should have their keyboard license removed from them) might think that bracing a compound structure which contains only one statement makes the code look uglier or more unreadable, but it definitely makes it a lot more maintainable.

(As an aside, I have a feeling that this is one of my more poorly written entries. Shame on me, I know.)

I Have The Worst Luck…

Thursday, February 12th, 2009

…with hard drives.

The event logs of a dying iPod.

The event logs of a dying iPod.

A few years ago I bought a Seagate 160GB hard drive, anticipating my imminent requirement for more disk space. Eventually, the time rolled by where I actually needed that space, and that’s when the abovementioned hard drive crashed spectacularly. It has since been replaced with a new unit which has (touch wood) been working smoother than yo’ momma’s thighs.

Fast-forward to a few weeks ago, where visions of impending doom filled my head when, once again, I had hard drive issues. Luckily (if you can say that) it was only (hah!) one of two things: my primary IDE channel had given up the ghost, or the cable connected to the primary IDE channel was busted. I haven’t tested either one of these hypotheses yet: my hard drives are working on the secondary IDE channel and that’s all I need to know.

But now, the latest victim in this sordid string of sick storage devices is my 3-month old 120GB iPod Classic. I’ve checked the drive’s SMART data in the iPod diagnostics menu, and the reallocated sector count is firmly within the range of 2500-3000, with more sectors pending reallocation. Never mind the fact that some tracks are irrevocably broken, pausing halfway through the song before skipping to the next file. The window pictured above is the Event Viewer on my computer after attempting to playback (i.e. read from the iPod itself) one of the affected tracks using foobar2000 (which, it so happens, gave up with an I/O error after quite some time).

So this weekend it’s off to warranty claims with my iPod, and with it goes just about any musical entertainment at work for the next week or two. Barring a daily selection of media to copy to my flash drive, of course. 512MB has never been so piteously small a capacity…

Also, Albert will now be chortling with self-righteous glee as karma destroys my iPod, after I (naturally) poked fun at him when his iPod Touch’ home button went on indefinite strike. That’ll teach me to laugh at other’s misfortune (even if they are part of the Turtleneck Cult and thus actually deserve it).

(Damn it, there goes my replacement iPod too.)