“Small” code or “Less” code?
February 21, 2007
A lot has been written about how programmers should aim for writting “small” code (actually I was just reading Jeff’s post). But programmers usually mis-interpret the term “small”. Small code does not mean that you start reducing lines by trying to push everything in one line of code and eventually make it a meaningless gibberish that not even aliens can understand. What those people really mean is that if you can get the same amount of things done with “less” code then do that. Make it small by thinking of a smarter way of doing that thing. Or using a better data structure. Or removing useless variables. Or removing repeated code.
Reducing code by doing something like the following is not always of much help. At times, its worse actually.
var c = F1(F2(F3((a==b) ? F4() : d)))
One of the most important use of smaller code is to make it easy to manage. I am not making it easy to manage by writing something like the above code. I am making it even harder to understand and hence even more difficult to manage later on.
Write ”less” code. Keep it clean and easy to understand. Write comments. Use meaningful variable names. Have fun!
What can we learn from packaging?
February 17, 2007
Last week I was going through this flu phase (weather change or I don’t know what). Anyways, instead of taking all those heavy anti-biotics to strengthen my anti-bodies alongwith my will to die, I decided to get packets of a herbal tea, Joshanda.
At night when I was so down with flu that everything seemed blurry, I decided to give Joshanda a try.
I tried opening the packet by the usual chips packet opening method. I wasn’t able to open it.
I tried tearing the corner. I wasn’t able to. Not even with my teeth.
I couldn’t find that black box printed, which usually tells which side to try opening either. I couldn’t think of anything I did wrong to whoever designed that packet either. Did they not want me to open the packet easily or something? They probably wanted to pack it good enough, so Joshanda’s essence doesn’t go out, but was that the only way of doing that?
I finally decided to use a knife, which I thought would definitely open it. Even that slipped off the glossy packet the first time.
I was almost crying with annoyance when I finally got it open and when I did, the water I had boiled had got warm. I poured it in anyways and had it. It was good and it helped my flu too but I just didn’t knew if it was good enough to go through all that trouble of opening that packet.
I realized how easily usability is neglected while designing products. I’m sure each of you would have realized this while using one product or another.
Dilbert’s chair
February 14, 2007
1/4 of 245 = around 61 days of work in a year
61 / 365 X 100 = around 17 %
If he works 40 years of his 70 year life then 40/70 years of 17% = 9.7 %
9.7 % of his life, Dilbert will sit in his work chair.
I don’t know about you but if I was Dilbert, I would want that chair to something awesome. I mean may be not like Santa’s rocking chair but still, it has to be awesome.
“Its the class of code you write”
February 13, 2007
I’m an Arsenal fan. I love to watch them play. I love their strategy. I love their team play. Its like they are kings of soccer. The weird thing is though, Arsenal doesn’t have the best record of winning games.
| When I listen to their manager I get a feeling that he doesn’t really want winning. I mean he obviously wants that but not as much as playing better soccer. And to tell you the truth, that is one of the most important things you need. I mean really, is it about winning matches or about the class of soccer a team plays? Don’t you like a team more if it plays better, even if they loose a few times, then a team who just wins somehow (not necessarily by playing better)? I mean we all know not the best team has to win always. | ![]() |
And you can see when a team has class. It could be just a tackle or an awesome pass or any other moment of magic they show. Like a beautifully written block of code. Or an easy to use, simple user interface. Right?
On Ruby On Rails
February 12, 2007
Of the following 3 methods of iteration commonly used in Ruby, for loop one is the most optimized one.
10.times do
#do something
end
1.upto(10) do
#do something
end
for i in 1..10
#do something
end
Oh but what the heck, I want better code readability at times. When I can, I love to use the one which sounds good…!
Digg deeper: Stack, Swarm & BigSpy
February 10, 2007
Digg is supposed to tell us which content users think as worth reading. In simple words, its a place where users rate stories by voting for it (Digging it) or against it (Burrying it). It’s really important that this information is represented well. The question is that by looking at the story listing and its Diggs, can we really judge if the story is worth reading.
I mean, are users more interested in reading whats popular or whats getting popular or what getting popular more rapidly. Consider the movie ratings at imdb (http://www.imdb.com). If a movie is rated 10 its doesn’t necessarily mean that its a really good movie. You have to look at the number of users who have voted for it also. If more people have contributed to the 10 rating THEN its good. So if a new movie gets listed, then its rating would be very unreliable.
How Digg took care of this problem is that you can view digg lists of a certain period of time (24 hours, 7 days, 30 days and 365 days). For new stories I will look at the 24 hour list and the Diggs for those stories help me judge whats popular.
To Digg deeper, Digg labs have introduced Stack, Swarm and now recently, BigSpy. http://labs.digg.com. These are real time representations to tell whats popular.
Stack. Stories are represented by stacks of diggers (represented as small blocks). Around 100 stacks are lined up and the diggers are falling from top and stacking up on the story they are reading. The bigger the stack of a story, greater the number of people who read it. Diggs are represented by the color of the stack. The brighter the color, greater the diggs. So, besides telling how many people voted for a story as worth reading, it also tells how many people actually read the story (it doesn’t tell the actual figure but it gives an idea).
Swarm. Stories are represented by small circles and diggers (represented by smaller yellow circles) swarm around these circles and make them larger. So the size of the circle gives an idea of how many diggers read the story. This representation shows less number of active stories but it also gives an added information. It tells how many diggers are reading the story currently and how they move to another story when they are done reading.
BigSpy. The representation lists the story titles as they are being dugg. So its kind of a real time list. The newly dugg stories keep coming from the top nad keeps pushing the older stories down. The font size shows the number of times a story is dugg. Its more oriented towards whats being dugg recently. Although it doesn’t give some of the information which stacks and swarms give, it is much simpler to follow.
I think different representations would work for different people but its important to have a real time representation to give a better idea to know whats popular, whats getting popular and whats getting popular more rapidly.
RSS feeds to GIF files
February 10, 2007
Check out http://www.rsstogif.com
All you have to do is enter the URL of the RSS feed and modify some settings like the background color you want etc. and it generates the HTML for that image. The idea is that you can transform your RSS feed into an autoupdated image.A very interesting use could be to use the image as your signature in forums or email.

