Bad Code

Early last week we delivered a build of our application to the “customers” that has all of the planned features. Not a big bang release of course, since we practice TDD and XP so we release often. Sometimes too often for our liking but that’s another story!

So we all were in bug fixing mode but the bug list is moderated by our domain expert so there are times when all the bugs are being worked on and no new bugs are in the tracker.

The standard practice when that happens is to look for code to refactor. The amount of code we have and the uneven level of skills in the team meant there are plenty of opportunity for refactoring. After I did some light refactoring on some UI code, I came across this piece of gem:

if (someText.Length > 0)


if (someText.Length == 0)


Needless to say phrases such as, “WTF?”, “You are fired!” (in Donald Trump style), and many others came to my mind. I knew who wrote this piece of code and it amazes me that someone who has years of programming experience produces this kind of sloppy code. Even college students won’t make mistake like this.

Perhaps it is a one-off, you say? Try another piece of code that I’ve seen from the same developer at another time:

string fooString = new myForm().MyTextBox.Text;

string fooString2 = new myForm().MyTextBox2.Text;

I could immediately see three problems here. First, using a TextBox’s text property to store a default string for later use? Should have used constants. Second, exposing a TextBox as public property? Third and most important, instantiating a form just to get access to some data inside the form that has nothing to do with the form? How expensive is that!

So this developer violated some of the most fundamental rules/concepts of programming (Encapsulation in Object Oriented Programming, anyone?) for what, I don’t know and I don’t want to know.

Anyway, I showed the first piece of code to another team member who I know is discreet but even he shouted “What?” rather loudly after reading the code. I didn’t dare to show it (let alone the second one) to the team lead or the boss because I knew Donald Trump will definitely make an appearance!

Technorati Tags: ,

The Sound of Silence

The next door neighbour recently has a baby. Being a new born, it cries a far amount day and night so we noticed its arrival a few weeks back. Last week, the husband finally came over and knocked on our door and told us about their baby. (Duh! As if we can’t hear its crying through the wall and corridor)

Anyway, apparently our prime time TV viewing with the sound system on is disturbing the baby’s sleep which is fair enough. Also my late night Halo 2 session chatters also permeate through the wall into their bedroom, which is adjacent to our living room. Fortunately I was still at work when he came over so I didn’t have to deal with the awkward situation/conversation.

So to solve the first problem Leah and I decided (via SMS) that we should purchase another set of the awesome Sony wireless surround sound headphones so we can watch TV in silence. The only downside is the even after being on sale for over 6 months Sony still hasn’t release a spare headphones for the same model. This forces us to buy an extra complete set in order to have an additional headphones!

Even though these headphones do not use the Dolby Headphone technology (they use Sony’s own proprietary technology, go figure) they still produce very impressive surround sound. So much so that Leah thinks it is the best thing since slice bread. (Ok, may be I was exaggerating a bit here)

As for the Halo 2 session, not much I can do about it apart from playing less during the night and being quieter.

Technorati Tags:

From 14 to 0

Watching the Lakers vs. Jazz game right now reminds me of the McLaren of the late 90’s. David Coultand would gain a sizeable lead and somehow by the end of the race, he would lose it by running off the road or something.

Lakers tonight led for most of the game, until 2 minutes before the end. At one point, Lakers had a 14 points led over the Jazz. They drew the game on a controversial foul at the last second (0.4 to be exact). Now they are on overtime.

And Kobe had just fouled out.

But they won 105-101 in overtime. No thanks to Kobe’s 11-33 FG% though…

Technorati Tags: ,

Website Built with

Up ↑

%d bloggers like this: