Category Archives: Rants

Sometimes you just gotta go off…

Bracket Style and Indenting Code

I’ll try to keep this short. Having been coding for years I’ve seen a lot of examples of how other people write code. Now while there are certain requirements in coding, there are areas where you can inject your own person style or preference. One area that has always bugged me is how code is indented and how brackets are used to separate blocks of code. Here’s a very simple example of how I normally code a simple if/else block:

if (hours < 24 && minutes < 60 && seconds < 60)
{
 return true;
}
else
{
 return false;
}

This is known as Allman style (named after Eric Allman, the developer of sendmail). The most common variant of this would be K&R style (from Kernighan and Ritchie’s book The C Programming Language) and the same code looks like this:

if (hours < 24 && minutes < 60 && seconds < 60) {
 return true;
} else {
 return false;
}

Equivalent in every way except readability. Some people call this “The One True Brace Style” because it’s been around so long. The major difference is that the opening bracket is placed at the end of the line that the control statement is on where in Allman style the brackets are each on their own line.

To me it makes sense to make code as readable as possible by lining up brackets to match the block they go with. It becomes apparent what blocks of code belong to what conditions.

Allman style
 
K&R style

If I was to have another condition nested within the example, it would look like this:

if (hours < 24 && minutes < 60 && seconds < 60)
{
 if(hours % 2 == 0)
 {
 	return true;
 }
 else
 {
 	return false;
 }
}

Again, very readable.

The funny thing about K&R style is that its roots seems to be based in the fact that programmers used to have to deal with limited screen space and by squishing the brackets together with the blocks that they belonged to, it saved precious screen real estate. Most programmers either picked up the style they use most often from learning coding in a class or by following the examples set by others, while other programmers code for readability, especially now that space isn’t the issue it once was.

While Allman and K&R are just two of the most popular styles (see
http://en.wikipedia.org/wiki/Indent_style
and
http://en.wikipedia.org/wiki/Programming_style
for some others and a detailed explanation about the history of each)

(please pardon the less than perfect wordpress code formatting)

What’s Wrong with Digg

I’ve been a regular Digg user for years but I have to say that their most recent design change both sucks and concerns me about the future of the site. This started not that long ago when Digg revised its comment system and made it virtually unusable. The comment system is a large part of the attraction of Digg and what was once a clean and simple interface became an ugly, nested series of blocks that got bogged down in the overuse of JavaScript and AJAX. Now I’m a big fan of JavaScript and AJAX but the designers of Digg need to take a lesson in moderation. It’s difficult to visually follow threads the way they have used blocks to separate posts and the vertical lines don’t help at all. The worst part comes when you try and open a story with a lot of comments. FireFox users will often be greeted with the message, “A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete” at which point you can kill the script, let it continue, or debug it. Another issue has to do with posting comments. I’ve personally seen the bug where comments simply disappear from the story I posted them to yet when I go to my profile it still shows that I made a comment. Some part of Digg knows I made a comment yet another can’t seem to find it. Finally, and I’m sure this is related to the AJAX issues, but stories with a lot of comments can’t display them all at once. Instead you have the option at the very bottom to display comments x through y. What bugs me about this, and maybe I just don’t understand how they’re counting, but a story with say 450+ comments only has a link to “Show 51 – 101 of 253 comments”. Huh? Does the 253 refer to top level posts? Does the 253 mean that I’m looking at a page with 200 comments and there are 253 more to see? The meaning of the numbering is not immediately clear and therefore becomes irrelevant. Digg’s founders keep promising changes in the comment system and other changes to the site but this has been going on for months now with no end in sight.

Going back to the issue of Digg’s most recent design changes, I have to say that it seems to be no improvement at all over what they had 18 months ago. There’s still no picture section, the design is getting more blocky, and now the front page is suffering from longer load times. Digg needs to be fast, clean and simple. Simplicity has always been the key to Digg. Keep the site lightweight, make it easy to contribute. That’s all.

My profile. Why can’t I select how many items I see on one page at a time? It’s still impossible to view each story I’ve dugg at once. Instead I’m forced to go one page at a time with 15 items per page. I tried to write a script using Digg’s API to do this but they limit the results you can pull there too.

Friends. I’m sure plenty of people enjoy the Friends section of Digg but being a rebel I really don’t give a shit about what story someone else has dugg. I’m sure it has it’s pluses but I go to Digg to explore, not to be lead around.

And don’t even get me started on Digg’s search.

Nickelback, Hinder, and the pathetic state of modern music

I can’t listen to the radio anymore. Free radio that is. I’ve had satellite radio for over a year now and it’s the only thing, aside from mix CDs, that I listen to in my car anymore. It’s obvious how the state of modern music has degenerated over the last decade or so. Now groups like Nickelback and Hinder, which sound damn near identical to me, plague the free airwaves.  Hate is a pretty strong word so I’ll just say that I can’t bring myself to listen to Nickelback, and their sound-alike counterpart Hinder. They’re horrible. I don’t know where to begin other than they’re the musical equivalent of a root canal. Even on the satellite radio shuffle channel I can instantly detect either of these talentless artists and when I check to see what’s playing, it’s inevitably one of them. Not to pick on these two bands but they need to do everyone a favor and pack up and go. There are arguable plenty of other talentless, fabricated musicians and bands out there that should join them. It’s rare to see an artist last for more than one album any more. Just look at the iTunes charts over the past few years and see what I mean. Oh and before you ask where I get off, I’ll just add that I worked with a Grammy winning musician for several years and leave it at that.

We are in a reverse renaissance.