Wednesday, June 08, 2005

Copy -> Brain -> Paste

People say that all that software engineers do is "Copy Paste". Here's a real life example why the Brain component is important.
I once wrote a code to get some data and cache it to make second time retrieval faster. Here's what the code for retrieval looked like that I wrote:

public ShowDetail getShowDesc(String territoryId,String showId) {
HashMap cmap = (HashMap)cache.get("somekey");
if(cmap==null) {
cmap = new HashMap();
}
ShowDetail showDesc = (ShowDetail) cmap.get(showId);
if(showDesc == null) {
logger.debug(showId+" not found in Cache ... Getting from Webservice");
showDesc = pwm.getShowDetail(territoryId,showId);
if(showDesc != null) {
cmap.put(showId,showDesc);
cache.put("somekey",cmap);
}
}
return showDesc;
}


Basically checking if the data exists in cache, if not, getting it from webservice and putting in cache.
Another fella needed to reuse the entire code (translation: copy paste everything). He probably didn't understand the concept of cache, or probably he did understand but didn't want to use it. Whatever be the case, here's the code that finally came out:

public ShowDetail getShowDesc(String territoryId,String showId) {
HashMap cmap = null;
if(cmap==null) {
cmap = new HashMap();
}
ShowDetail showDesc = (ShowDetail) cmap.get(showId);
if(showDesc == null) {
log.debug(showId+" not found in Cache ... Getting from Webservice");
showDesc = pwm.getShowDetail(territoryId,showId);
}
return showDesc;
}


The first 2 lines itself are amusing enough for starters. I used to laugh on such things some time back, but it not funny anymore.

Friday, June 03, 2005

Bunti aur Babli

Yeh world hai na world, isme do tarah ke log hote hai. Ek jo bunti aur babli ek hi baar dekhte hai aur dusre jo bunti aur babli ek se jyada baar dekhte hai. Hum dusro main se hai.

I enjoyed it more the second time. Why ? Because I knew by that time that movie is pure comedy and even the supposedly thrilling sequences are also comedy.
The movie doesn't get boring even for a minute. If I break the movie into infinite parts of infinitesimal frames and rate each frame, each of them will get atleast a "decent" rating.

The weak part? Lack of details. The movie has too many cases due to which each case doesn't get enough details for viewer to understand how exactly they did it. This also made me wonder why do they become so popular by interval that every newspaper is publishing their news. The cases lacks the certain spark to distinguish them from ordinary thugs.
Secondly, the lack of thrills. bunti and babli do not actually live on the edge. Even though Big B himself is behind them, their life is pretty easy most of the time. Wasn't really expected.

However, its being a long long time since I saw "housefull" in the theatres in jaipur and all three bunti, babli and DCP dasrath deserve the credit for their fine performances.