Monthly Archives: May 2006

f(f(x)) = f(x)

This property is called idempotent.

What has this got to do with software?

Enterprise software constantly deals with upgrading data. Of course, as this is a very challenging and complex task, most small/medium s/w companies, I believe, don’t invest time and effort doing this. But that’s a different topic. However, if one were to embark up on such upgrades, one of the things that’s required is to make the upgrades idempotent.

Writing the upgrades that are idempotent ensures there is no data corruption and that the scripts are run faster.

Leave a comment

Filed under Tech - Tips

Coding without concepts

* String a = new String(“abc”);

* Defining a constant as : private double PI = 3.14;

When you see this type of code, then the person writing it probably know coding, but doesn’t have a good understanding of programming.

Want more snippets?

* String sql = “select abc,xyz” +
” from def” +
” where ijk = mln”;

* public SomeConstructor() { abc = new String(“”); };

I am not making these up just for filling up a blog. These are the kind of code I encountered in my professional life.

Leave a comment

Filed under Uncategorized

Ads, Memory, CPU cycles, Power and a Great Monkey!

Oflate, the number of flash ads is increasing leaps and bounds. Perhaps, with the wider adoption of broadband, it’s no big a deal to let a fat ad take up some of the bandwidth. However, the number of flash ads per page is also increasing. With everyone trying to take the top and one of the sides areas for ad displaying, there are atleast two ads per page, if not more, and the chances of both being flash ads is only increasing.

But the biggest problem is, these flash ads are really flashy. Which is quite a bit of distraction. I can sit 10 feet away from a TV and watch a lot of change on the screen. But sitting a feet or two away from a small monitor, the pain these flashy ads cause is intolerable. On top of it, many of these ads have looping on. If only the Macromedia guys provide an option for the end users to decide if the entire flash content can loop or not! So, these ads are network hog, memory hog, CPU hog and with the soaring energy prices, they are also costing the end user!

So, what can be done to ban these unwanted ads? That’s where GreaseMonkey comes into picture. First, switch to Firefox and then get the GreaseMonkey plugin. Then install the Flash Blocker user script and you are set. Also, search for other user scripts that block Google ads and other ads. Another of my favorite user script is the one that converts all the mailto links to normal text with an explicit mail image. So, before you click and bite your tongue while the OLE/COM/DCOM or whatever it is doing it’s magic to open up your favorite mail composer, you know before hand that it’s an email link.

Back to ads. Ads are fundamentally not evil. Ofcourse, who doesn’t enjoy very creative ads now and then shown on the TV? Imagine watching a TV show which has ads every 1 minute. Same with these flashy, large space occupying ads. When something is not annoying people can bear with it. Otherwise, they will try to find every possible way to get rid of it.

Take Google ads for example. It was a huge success. Among various other reasons, for the simple fact that they are not flashy and distracting. However, the Google guys got gready. Instead of “will index every page on the web”, they sort of became “will put an ad on every page on the web”. Net result? I started looking for a way to knock of such ads as well. And with GreaseMonkey plugin, and some excellent user scripts, I am able to get rid of some, if not all, those Google ads.

So, my advice to anyone is, don’t get too gready.

Leave a comment

Filed under Uncategorized

OneBox, OneField, OneBrowser

When I understood why Google’s OneBox was named as “One Box”, I thought that was a smart name. But then, today I came to know a similar concept in Firefox’s Bookmarks.

The best way to keep knowing a lot of English is by constantly using dictionary. In the olden days it was painful using the book dictionary to find the meaning. Ofcourse, weighted binary search helped speed it up, but still painful.

The best way to keep the kids use their comptuer time, is to hook them up to the electronic dictionary. So, anytime they need to know the meaning of a word, they just have to walk up to the desktop/laptop and fire up the search.

How to make this search as simple and painless? That’s where Firefox’s bookmarks come into picture.

Just open the bookmarks menu, manage bookmarks, new bookmark, then

1. Enter name (Dictionary)
2. Location (http://dictionary.reference.com/search?q=%s)
3. Keyword (d)
4. Description (Searches dictionary)

That’s it. Now in the browser’s url, just type “d serendipity” and there you go! Happy learning.

Anyway, don’t know if OneBox came after Firefox’s idea or the other way. Both are one and the same conceptually. There is one and only one box (the text field where you type in url , search word etc). And that’s all that’s needed to get all the info!

Leave a comment

Filed under Uncategorized

Blur the background

Recently I saw a cool behavior on one of the B2C websites. After adding to the cart, a separate layer was displayed with a close button. And the original page was blurred and no action could be taken on the original page till the layer was closed. Sort of a modal window behavior, but without opening a separate window.

It took a while to come up with an idea on how to do it. Once I got it working, it felt good.

2 Comments

Filed under Uncategorized

Shortest Path

Long back when I came across

while(*str2++=*str1++);

I was so excited. I thought to myself, this is how I should write the code, elegant and terse, for the rest of my coding career (mind you, not “rest of my life”).

When a code does no more than what it should do, it automatically becomes more comprehensible. Ofcourse, I am not advocating one should code in assembly language.

Leave a comment

Filed under Uncategorized