15 Jul 2007
Thanks Chinmayi
You wake up in the morning and switch on your computer. You find that there are 95 scraps in your Orkut profile. Many of them are from strangers whom you have never seen and quite possibly won't ever see in your life. How would you respond to those scraps? To be honest, I would just delete my Orkut profile and get away from there.
But Chinmayi, the singer, responds to most of scraps (or maybe all of them?). Yesterday I just found her profile in Orkut, and I couldn't resist my want to say a "Hi" to her. I don't know anything about music; I just listen to songs as a not-so-serious hobby. I like Chinmayi because of her voice. After reading her blog and seeing her on Vijay TV, I really started liking her personality. I could even say that I am a fan of her.
When I wrote a scrap on her Orkut scrapbook I didn't expect her to respond to my scrap. I know she is very busy. If my assumption is right, Carnatic music practitioners like her do practice daily for at least a couple hours. All the weekends she has concerts. As she is working in the movie industry, most definitely she will have to meet with many important people.
Surprisingly, I got a response from her! I was really happy to see her scrap on my scrapbook. When I searched for my scrap in her scrapbook I got the next surprise: 95 new scraps have been written on her scrapbook in one single day! And, she is taking time to respond to my scrap. Most definitely she doesn't know me, I am not ever going to meet her at all in my life. But still she takes the time to acknowledge my message.
She has about three blogs and a web site. In addition to these many scraps, she would get comments for her blogs, feedback for her web site, and emails sent directly to her mailbox. All I could think of is that she is a good woman. I want to thank her for the respect she has shown to my message. But this time I just say it here, in my blog -- because I don't want to spam her again. Thanks Chinmayi!
4 Jul 2007
Code Duplication
You might have heard people talking about not duplicating code so that it becomes easy to maintain. Back those days, I didn't know all these and used to make a hell lot of mistakes while programming. By the word mistake, I mean doing something that makes developing and maintaining software harder than it ought to be. Of course, that helped me learn a lot of principles.
The first thing I learned from my mistakes is not to duplicate code/ideas. Since I was bit by duplicated code very often, I try my best to reduce duplication as much as possible. In this post I am giving a few examples to show how I try to avoid duplication.
Obvious Duplication
The first pattern I recognised in my code was something like the following.
if exam.mark >= 35:
exam.result = 'pass'
logging.debug('Setting result to pass.')
return 'pass'
else:
exam.result = 'fail'
logging.debug('Setting result to fail.')
return 'fail'
Obviously this code is duplicating ideas, so must be refactored. How will you refactor this to take away the duplication? I will write it this way:
if exam.mark >= 35:
exam.result = 'pass'
else:
exam.result = 'fail'
logging.debug('Setting result to ' + exam.result)
return exam.result
(To be more precise, I will also replace the literals 35, 'pass', and 'fail' with appropriately named constant variables.)
More Subtle Cases
This is (part of) a PyUnit test case for an imaginary function double, that takes a number and multiplies it by 2.
def testDouble(self):
inp = 5
expected = inp * 2
actual = double(inp)
self.assertEqual(expected, actual)
Here, I have used the variable inp to avoid having to duplicate the test input I am passing to double.
As another example, see this code that assigns a grade to a student based on the mark they have scored.
if mark < 35:
grade = 'N/A'
elif mark >= 35 and mark < 50:
grade = 'D'
elif mark >= 50 and mark < 70:
grade = 'C'
elif mark >= 70 and mark < 90:
grade = 'B'
else:
grade = 'A'
I would rewrite this code like this to avoid duplication of the boundary values (although this is a very small duplication).
if mark < 35:
grade = 'N/A'
elif mark < 50:
grade = 'D'
elif mark < 70:
grade = 'C'
elif mark < 90:
grade = 'B'
else:
grade = 'A'
Tell me about the ways you follow to make your code more maintainable.
1 Jul 2007
Web Development 101
They say a picture is worth 1000 words. So a video should worth more than a picture. Definitely a hands on experience is worth much more than a video. All you starting web developers: here is your most important lesson. I'll tell you what I did to learn this lesson. If you follow what I did, hopefully you will also learn :-)
Steps to follow:
That's all for now. Now you're free to dream about your cool web site.
- Think of a very good Tamil song that you don't have right now, but would love to add it to your music collection.
- Google for it and most likely you will get a link for that song in Raaga.com. (If not pick another song; in this particular exercise, we are gonna learn from Raaga.com.)
- Click on the link in Google results and if you are lucky, you can listen to the song in their site. If you run any non-Windoze OS you're doomed.
- Then you decide: alright, I really like this song and I'm gonna download. Click on "Download" button. You will be politely informed (with a JavaScript alert) that you got to log in if you want to download.
- So, you click on Register link. And you know the rest: I am too lazy to type all that now.
- You will have to activate your account, this, that, and all other bullshit.
- After you have downloaded that song, sit back and think "do I want my site to be as brain-damaged as Raaga.com?"
That's all for now. Now you're free to dream about your cool web site.
14 Jun 2007
No peace yet :(
Nowadays every single day I am reminded of Tamil Nadu politics wherein there are effectively only two parties and people have no idea which one to vote for. Because both are equally bad. I switched from Windows to Linux because Windows was buggy and it could not stand my usage for more than 2 or 3 days. It kept crashing all the time and "Click OK to restart your computer" dialogue boxes were freaking me out. Now my Kubuntu installation is good by itself; but the awfully f***ed up Flash Player for Firefox makes Firefox unusually and intolerably slow, unresponsive, and whatnot. Jeez.. when are we going to get a good computer with software written by responsible human beings who could empathize with the real users. I know, this is how life is; but it just sucks :-(
11 Jun 2007
Linux to Windows to Linux
Well, I am now moving back to Linux. I installed Windows on my laptop a month back (because I missed some Windows applications) and was using it till yesterday. There are certain things about Windows that just piss me off:
- Mediocre shell (not the command-line shell): Windows GUI needs a lot of improvements. Forget those usability metrics; it crashed five times in two days (yesterday and the day before). I usually keep too many windows and a number of Firefox tabs open. And whenever Windows shell crashes I am forced to log out and log in to get that stupid shell again. It just sucks. All my applications lose state (well, almost all). After logging in back, it takes a while for the computer to become stable because there is a ton of things happening in the startup.
- Software updates: While I always want to keep my computer up to date, Windows uses a poor model for overwriting a file which is open now. Upgrade IE? Restart computer. Upgrade Windows Media Player? Restart computer. Upgrade Adobe Reader? Restart computer. Security updates for Windows? Restart computer. I simply could not tolerate this nonsense. When I was running Kubuntu, I have had my computer running for about 2 months without restarting or logging out. Just hibernate and wake up. All the while I was updating all kinds of software in my machine. It just works.
- Slow apps, slow devies: as soon as I insert a disk inside the optical drive, the whole system including all the apps and OS just stalls for a few second. Until Windows recognizes the CD, you got to wait. No need to say that Microsoft applications (like IE, WMP, Office, etc) are irritatingly slow and occupies all of our system resources. (I don't use them at all; but they are part of the computer. They get automatic updates, this that etc.)
- Backup: When in Linux, all I needed was a single command to backup all my data to my iPod. But in Windows land, I have to search hard for a free backup software, install it and learn it's stupid user interface before using it. Heck, it takes hours to do incremental backup. Linux does that in a few minutes.
Subscribe to:
Posts (Atom)

