Wednesday, November 30, 2005

Ruby Tuesday @ Xiamen(China)

I know that Perryn has already blogged about this; I'm just reiterating it. A group of us Thoughtworkers have started a small Ruby interest group here in Xiamen. We meet up every tuesday at 6:30 pm at Cafe Relax (near Xia Da) and read/pair/experiment with Ruby. We've had an impressive response so far (6 TWers and 2 local geeks, with one client developer dropping in occasionally). Perryn and Andy are writing a game(called "Go") in Ruby; their idea is to add as many new ruby features as possible and not really bother about good design.

I am really enjoying playing around with Ruby. It seems to have a few similarities to Java, but a lot of "new" ways of doing things (sometimes it makes you wonder why Java doesn't have those features). The only setback is the lack of a good IDE. I am currently using Eclipse with the RDT pluggin which provides syntax highlighting and (very little) context sensitive help. (When you've been working with IDEA or Eclipse for a while, it feels unnatural to type code!!) .

Anyways, If you are in (or around) Xiamen on a tuesday evening, and want to learn/discuss Ruby, make your way to Cafe Relax and look for a table with a lot of laptops (and some food :-).

Sunday, October 30, 2005

China : The Good, the Bad and the Ugly

I have lived and worked in Xiamen, China for the last 4 months. Its been an amazing experience, to say the least. I shall try and articulate my experiences/thoughts on what I liked and disliked during my stay there.

The Good

  • The people are simply great. They go out of their way to help others (including the “Laowai” --- Chinese for foreigner), even if they don’t speak the same language. There was this one time when Conrad and I wanted to board a bus but we didn’t have the exact amount of cash. Looking at our dilemma, an old Chinese lady (a complete stranger) actually offered us the required amount!!
  • The infrastructure is mind-blowing (compared to that of India).The public transport system is really clean and nice; Roads and sidewalks are wide and well made. The big cities like Shanghai and Beijing are well connected through subways. Shanghai in particular is simply awesome. It’s a well planned city with loads of high rise buildings and some amazing shopping malls. It’s also got the Maglev train which runs at 432 kmph!!
  • When it comes to food – the Chinese are definitely on top of the food chain. Meat constitutes the main part of their diet. Though this is not particularly great for vegetarians like me, the carnivorous humans :-) seemed to like the food a lot.

The Bad

  • Software piracy is quite rampant in all parts of China. One can get any DVD (Movies, MS Windows, Adobe Photoshop, games… literally anything) for 8 RMB (approx. 1 USD). You’ll find stores selling these pirated DVDs everywhere, not just in some shady streets. I don’t understand what the government is doing about it.
  • “The great firewall” can lead to some frustrating times. Quite a few blog, news and web hosting (geocities, bravenet, netfirms etc) sites are blocked. I haven’t blogged in 4 months since blogspot is blocked in China L. Google news was blocked until a month ago. Hope the government realizes this is doing more harm than good.

The Ugly

  • I personally hate “Chinese traditional medicine” for what its done (and still doing) to the populations of tigers in the wild. The Chinese make use of tiger bones to prepare some of their “traditional medicine”. This has encouraged poaching and pushed the south China tigers to the brink of extinction (there are only about 20 left in the wild!!). Now, the Indian tigers are being killed to satisfy the demand. The Indian forest department is making an amazing effort to save the tiger from extinction; it hurts to see that this is a losing battle because of the “medicinal” products from China. I hope the Chinese are educated about the evil effects of their “traditional medicine” before its too late!

That said, I still miss China a lot. I’ve made some really nice friends out there (Thoughtworkers and the locals) and really liked hanging out with them. Looks like there’s a good chance that I would have to go back to Xiamen for a couple of months :-). Hopefully this time I would get to see a panda.

PS :- Some of you may regard this post as unprofessional. I never intended it to be “professional”; It’s simply a collection of my experiences/opinions. I apologize if I have offended you in any way.

Monday, July 04, 2005

Ni Hao

Its been about 2 weeks since I arrived here in Xiamen, China. The place is really beautiful and very clean. It’s an island in south east China (very close to Taiwan). Language seems to be my primary problem out here since not many localites speak English. So I'm trying to learn Mandarin :-) . Here nearly everthing (Billboards, business cards, magazines, sign/navigation boards... even Windows !!) is in mandarin. As Bhavin puts it -- "We work with 128 bit encrypted version of Windows !!"
We do get veg food.. and that's how i'm surviving here. I've learnt to use chop sticks pretty well now. Its good fun using chop sticks (atleast its fun until you drop something on the table :-))

Red Eared Slider

Lotsa places to visit around here. So far have only been to the Amoy botanical garden. Its really huge and beautiful. I've got a lot of snaps but I cant upload them coz the network connection is very slow here. I've taken some good snaps over here. The one above is a Tortoise (a red-eared slider as identified by Naveein from INP) which I found in our backyard. I havent had any luck trying to photograph pandas yet :-(
I was shocked to find out that China blocks all blogspot sites !! (although I can login and post something.... i cant view it, or for that matter cant view any blogspot site !) . Thats the update for now. Hopefully, I'd be posting my experiences regularly.

Monday, June 06, 2005

Rock Agama

Found this guy in my neighbour's garden. Couldn't identify him immediately, but then found out that he is a rock agama. Here are a few links which provide some info about this reptile :-

I would have loved to get a better shot at it. But my Canon A75 with a 35 - 105 mm lens doesn't help me in taking good close up shots. I'm considering buying the Canon S2 IS sometime soon. Why am I not buying a DSLR ? Well.. Its quite expensive to buy one. A Canon 350D along with a 70-200 mm lens would cost me about $1500 !! Any opinions/reviews on the S2 IS ?

Wednesday, May 18, 2005

Land of the Tiger

This is extremely disturbing news !! (Here's the Hindu and Deccan Herald version of the same story). 352 Tigers fall prey to poachers in the last 5 years! Why are these people killing tigers? Obviously for the money that accompanies a dead tiger. Its skin, teeth and nails fetch a lot of money.
How can we help? Well, sites like the and provide some information on how we can help. The most important thing to do is to stop buying such stuff and look down on people who do buy it (I would say... kill those bastards) .
Someday, I hope I would work like Valmik Thapar and Fateh Singh Rathore and help save the tiger. But until that day, I will have to write code to make a living :-).

PS :- Here's a gruesome video (taken from Anirudh's blog) which shows how animals are stripped of their fur to make fashionable dresses for us. I guess its high time for us to push back and stop supporting trading of fur, leather and other animal body parts.

Monday, May 09, 2005

Hibernate in Action

I have been trying to learn to use Hibernate over the last couple of days. After reading through the first 2 chapters in Hibernate In Action, I decided to try the "Message" example mentioned in the book. I used HSQLDB to persist the data. Initially I thought that we only needed to add the jdbc driver (i.e hsqldb.jar) and hibernate3.jar in the classpath. But then, a whole series of exceptions hit me in the face one after the other. Reading through the stack trace and resolving the exceptions one by one, I finally figured that the following jars need to be in the classpath for the program to run successfully.
  • the jdbc driver (in my case hsqldb.jar)
  • hibernate3.jar
  • asm.jar
  • cglib-2.1.jar
  • commons-collections-2.1.1.jar
  • commons-logging-1.0.4.jar
  • log4j-1.2.9.jar
  • jta.jar
  • ehcache-1.1.jar
  • dom4j-1.6.jar
All of these jars (except for the jdbc driver) come bundled with hibernate 3.0.

While specifying the configuration options for hibernate, we have 2 options --- either to use the file or the hibernate.cfg.xml. There are subtle differences b/w these 2 methods :-

1) If you are using the file --- While building the SessionFactory object, we don't need to call Configuration.configure() , but we do need to call Configuration.addResource() to specify the mapping files. i.e. --
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.buildSessionFactory();

If you are using the C3P0 connection pool, you need to add c3p0- (comes with hibernate 3.0) to the classpath.

2) If you are using the hibernate.cfg.xml file --- While building the SessionFactory object, we do need to call Configuration.configure() , but we don't need to call Configuration.addResource() to specify the mapping files since we could specify it in hibernate.cfg.xml itself. i.e. --
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.configure().buildSessionFactory();

Hope this helps when you are writing your first hibernate program :-)

Tuesday, April 26, 2005

Visit to Bannerghatta

The majestic white tiger at bannerghatta

On Sunday, I had been to Bannerghatta wildlife sanctuary with a few friends. It was an amazing experience, although it was very depressing to see the human population surpassing the animal population at the sanctuary. We got to see a whole lot of wild animals --- Indian Python, Rat snakes, Russell’s vipers, King Cobras, Zebras, Bears, Leopards, Tigers, Lions, Hippos etc. I believe there are about 35 tigers at the sanctuary, including 3 white tigers. I didn’t get very good shots of the big cats as I hoped to get. Here are a few snaps that we managed to shoot. I wish I could take a break from work and shoot some more of the wildlife. Anyone willing to sponsor a wannabe wildlife photographer ??

Saturday, April 09, 2005


I was discussing with Sheroy about persistence frameworks and the need for O/R mappers in Enterprise applications. We were talking about Hibernate and how it is being incorporated in EJB3 specs. The conversation then (naturally ??) shifted towards OODBs. There seems to be quite a few advantages of OODBs.
The most significant advantage of OODBs is that we eliminate the need of a separate data model. The data model just reflects your object model. Most modern Enterprise Applications have different object models and data models, and an O/R mapper to map the objects to rows in the database. This adds another layer of complexity to an already existing complex system, at a substantial cost. An OODB eliminates the need for this layer altogether.
If your application uses an RDB and you must reconstruct an object from data in the database, you frequently have to perform multiple queries. These queries could result in serious performance bottlenecks if not written efficiently. Constructing Objects from OODB records is straightforward. Another advantage with OODBs is that we don't require a separate query language like SQL. All the queries can be written in the OO language itself.
If OODBs have all these advantages, why are we then stuck with RDBs yet ?? Here are a few reasons that I could think of -
RDB is a proven technology which has lasted the test of time. From legacy systems written in COBOL, to applications written in Java/C# interface with RDBs. This allows the us to change the application technology to enhance scalability, performance and security and still use the same data model. This is a significant advantage, since the persistent data is considered to be the vital part of an application. OODBs on the other hand, tie us to a specific programming paradigm (and possibly to a particular OO Language) .
OODBs are an excellent tool for storing and retrieving objects. Most applications do not always load objects. Rather, there will be times when we need to search by ranges, patterns, and fuzzy criteria spanning objects that do not have obvious relationships. OODBs may not provide adequate support to such ad hoc queries.
All said and done, I think OODBs are a great way of working with data, and definitely worth a closer look.

Thursday, March 17, 2005


Photography is my latest craze. I have developed an interest for digital photography ever since I got my Canon A75 a few months ago. Although, this camera doesn’t have SLR like features, it’s good enough for beginners like me to get started on photography. Once I get really good at the art of photography, I hope to buy the Canon Digital Rebel (EOS 300D) or the Nikon 70D or some other Digital SLR….
I have been playing around with Adobe Photoshop for a couple of weeks now. It’s probably the best piece of software that I’ve ever used. The number of tools available is simply mind-boggling. I have never really used GIMP, but I am told that GIMP supports quite a lot of features that Photoshop currently provides. Guess, I’d be experimenting with GIMP sometime soon.
I have uploaded a few shots that I have taken at . I have also uploaded a few Photoshop effects that I’ve experimented with. Hope to update it as frequently as possible. Feedback/Criticism is welcome.

Thursday, March 03, 2005

Bad usage of instanceof

If ( Object instanceof ClassA || Object instanceof ClassB){
// do something

I have come across such code in many applications. Why would developers write such horrendous code? It clearly beats the whole purpose of polymorphism, doesn’t it?

Consider ClassA, ClassB and ClassC implement an interface (say InterfaceA). Wouldn’t the code look more elegant if we add a method to InterfaceA (say doSomething()), implement the method in ClassA and ClassB and provide a dummy implementation in ClassC. Then, the code would look like


The problem with this approach occurs when there are too many implementations of InterfaceA and only a few of them need to implement the method doSomething(). In such a case we could create an Abstract class (say AbstractClassA) which provides a default implementation of the method doSomething(), and override the method only in those few classes. I really think this would be a more elegant solution.

Having said all that, I fail to understand why the instanceof operator was provided in the first place!! Is it only to promote short term hacks like this??

Thursday, February 17, 2005

Mac at first sight

Last weekend Rajesh had got his new Mac G5 to the office. It was simply superb, to say the least. Karthik and I used the machine for sometime and we were totally bowled over by the features. This was the first time I was using a Mac. I have seen the ibook and the Powerbook, but never really played around with them. This was my first shot at it. In one of my previous posts, I had mentioned that Microsoft was “arguably” the best UI designer. I couldn’t be more wrong!! The UI of the Mac OS simply rocks. It’s a lot more responsive and has tons of visual effects. Also, there’s the familiar bash shell for the console freaks.

We were looking through the hardware configuration of the machine when suddenly something called AirPort caught my attention. Guess what that is! It’s the wireless port! Come to think of it, the name actually makes a lot of sense, doesn’t it?

There’s one thing I dislike about the Mac though. It comes with a single button mouse!! To right click, you need to hold the command key and click. Also there’s no scroll wheel !! The right mouse button and the scroll wheel makes life so much more convenient while using a PC. What were those Mac designers thinking?? It’s like giving the next generation computer with a 20th century mouse.

Friday, February 11, 2005

Unit testing

Everyone knows that unit tests are important. Besides providing a fine grained testing approach, they also help in asserting that the critical functionality is not broken after refactoring. Of late, I'm facing a few problems while writing Unit tests.
While adding some new functionality to the application, I had to modify an already bloated method (approx 80 lines of code) and add a few more lines of code to it. My pair and I didnt want to do this for 2 reasons :- Firstly, the method does too many things by itself and hence becomes unreadable. Secondly, its a nightmare to test such a big method. So we refactored it into a couple of smaller methods and implemented the new functionality. All goes well !!
Not so soon !! We then decided to test the new method ( yeah... we didnt do TDD !!). The method takes a data object as a parameter which has more than a dozen of fields in it. So we created a stub of the data object which implemented only the required getter and setter methods. When we passed this stub as the argument, the test failed !! Apparently the method used some Utlility class to convert the data object to a Domain object (which obviously required the data object stub to implement most of its methods). So now what ??
We moved the call to the Utility class to another method. It looked something like this --

Class foo{
public void method(DataObject data){
//do something;
public DomainObject convert(DataObject data){

Now to test this method we subclassed "foo" and overrode the "convert" method such that it returns the Data Object with only the required members set. The test passed.
I am not impressed with this style of testing though. What was the whole point of the test ?? At the end we were just testing a proxy implementation instead of the actual implementation. Is this the only way to test such methods? If you are aware of a better way to test such methods, kindly post a comment about it :-)

Tuesday, February 01, 2005


Google never ceases to amaze me. What started of as a simple searching tool for web pages, is probably the most sophisticated searching and indexing tool that we humans have ever come across. And its not stopping there !! Keyhole, Orkut, GMail, Google News (to name a few) are few of its offerings to its users.

There are a lot of things i love about Google. They have changed the very idea of UI design. Most of us assume that a flashy UI with loads of graphics would attract users. Google seems to have proved it wrong!! Its probably the simplest UI design that i have seen. (It has worked so well that even Microsoft, (arguably) the best UI designer has decided to "copy" them in their search engine).
The other thing I like about Google is that most of their developments seem to be triggered by interest and experimentation, rather than for commercial purposes. Consider GMail; Who would have even had the thought of offering 1 GB of email space ? But the moment Google announced it, many email providers scaled their service to offer atleast 250 MB of email space (Though MS was slower than a snail in catching up!!). I do not think that GMail was developed primarily to serve Google's commercial interests. And the idea of content based advertisements totally rocks!! Its such a boon to advertisers; Their ads are now targeting the right audience (well... mostly) and the best part is that they pay rightly for it, rather than pay for some random number of meaningless hits on some other web page.
A few interesting developments from Google that i have noticed :-
  1. You can lookup definitions of terms on Google : try --- define robotics
  2. You can evaluate mathematical expressions on Google. : try --- sin(45) etc.
  3. Convert units in Google : try --- 15 miles in inches.
  4. Look at for more ultra cool stuff from Google like Google Suggest, Personalized Web Search and Google Sets.
I also happened to come across Googlism which is created and maintained by an Australian company. Its a pretty cool site which shows you all the information that Google knows about any person/place/date etc. Pretty cool eh ? If you are aware of any other cool tools from Google, please do post a comment about it.

With all this said, there are few things that I dislike about Google !! Firstly, Google doesn't categorize its searches. Search engines like Clusty and iBoogie do this and I find it tremendously useful when I am looking up on stuff like "Artificial Intelligence" or "Compilers" etc.
The other irritating part about Google's toolset is that its only supported for the Windows platform !! How could they do this ?? Considering the fact that almost all of Google's servers run Linux !! I know that Mozilla has its own Google Toolbar but wouldn't it be better if Google inherently supported it, and not just IE ? And why not a Google desktop search for Linux ? I am aware of beagle, but I am still wondering why Google didnt do it?
Last but not the least, what is Google India doing ?? You can use Google to search for places in the US (i.e Google local) but it still doesnt have a local version for India!! I cant search for pubs in bangalore and expect a map and addresses, but searching for pubs in New York shows Local results with a map !!

Guess what !! I am listed on Google !! Seriously !! I was searching for my name (Chirdeep Shetty) on Google and the very first result is a link to my blog !! On the same result page, if you notice the 7th result, its a link to Anirudh's blog (listed here only coz my name appears in his blog). So now you know what to do to get your site/blog to be listed on Google :-)
And finally, If you have the time, do check out this flash presentation on the future of Google. Its quite interesting.

Monday, January 24, 2005

The Power of 1

Has ‘1’ lost its significance in today’s world? Who cares about 1 rupee today, when people are earning hundreds of thousands of rupees!! Do we even care about 1 second in this fast paced world? What difference can 1 person make to the way we live/ do things? The Answer ---- NO, I don’t think ‘1’ has lost its significance! Let me explain…
I have been tracking shares of Pentasoft Technologies for about a month now (The financial results of the company suck, but the share price seems to be rising due to the trading volume). Last month it was priced at 2.65 Rs./ share. Today it is at 3.70 Rs./share. How does this matter? Well, consider you had bought 10000 shares last month, investing 26500 Rs. Today, it would fetch you 37000 Rs!! ( I do agree that it is a risky proposition, but that’s not the point I am trying to make here). Do you see the significance of 1 rupee?? This is what stock markets teach you --- Every rupee counts.
Have you ever had to wait at a traffic junction for the lights to turn green? Do you remember looking at the timer impatiently, as it was ticking every second? We don’t realize how 8 hours go by at work, or for that matter, how 4 years pass by at college. But every second at a traffic signal brings down our patience exponentially!!
Can 1 person really make a significant difference to our world? Think again! How many developers did it take to write the first Linux kernel? Do you realize the support for the kernel today? Numerous devices from PDAs to PCs, from wrist watches to supercomputers run Linux. Some of the worlds largest companies like Google, IBM, Hp, Motorola (ThoughtWorks??) etc run their businesses on Linux.

The message that I am trying to convey is that ‘1’ is still significant in today’s world and will continue to be so in the future. One person can definitely make a significant difference. It’s up to you – give up, or accept the challenge.
Quoting M.K. Gandhi
First they ignore you, then they laugh at you, then they fight you, then you win.

Tuesday, January 18, 2005

Mullainagiri Trek

I had been on a weekend trek to Mullainigiri with a few colleagues from TWI. We had loads of fun on the trek -- exploring caves (with bats in them !!), hitching a ride on the roof of a bus, etc. On the first day, we began the trek at Mullainagiri. It was a relatively short trek and we were at the peak after about two and a half hours of trekking. We enjoyed the breathtaking views from the peak and then began exploring the caves near the peak. We went about 30 ft into these caves and found loads of bats (hanging upside down ofcourse !!) in them. This was our cue to get the hell out of there.
After having lunch at Mullainigiri, we began the second part of the trek to Bababudainagiri. It was pretty good initially, but then we had to walk about 5-6 kms, which was pretty tiring (considering we had climbed Karnataka's highest peak in the morning !!). We then took a jeep back to Mullainagiri. (It was a pretty adventurous ride, with a couple of punctures on the way !!). You can view the snaps here -- 1) My camera , 2) Sumukh's camera

Sunset at Kemmangundi

The next day, we hired a Tata Sumo and went to kalathagiri falls. At first, it was disheartening to see the falls (it was like tap water falling), until we figured out that the actual water fall was further up. The water was freezing cold and there was a natural water slide too. We had a ball of a time going down the slide. After spending a few hours playing in the water we headed down to Kemmangundi. This place is definitely not a trekker's delight, but is a wonderful place to check out the sunset. We then returned to the Chikkamagalur bus stand and boarded the bus back to bangalore.

Monday, January 10, 2005

Semantic Diff

Hari and I happened to read an article on Martin’s blog about Semantic diff. It talks about a smart diff utility that not only displays the difference between the two files, but also the refactoring changes that have been implemented. Traditional file diff utilities display the changes that have occurred in each line, given two source files. They do this because they treat both the source files as simple text files. But is this really the way to do it? Are source files just simple text files?

We don’t think so. We believe that source files should be treated as a stream of tokens / blocks. Consider a Java source file; The package declaration, Import statements, comments would be separate blocks. A Class/Interface definition would be a block which could contain other blocks like inner classes, methods and member declarations. Now the diff utility needs to compare the different blocks that it has identified. The order of these blocks would not be important. For example, a developer may choose to rearrange classes or methods inside classes. A traditional diff utility would show a thousand differences between the two versions, but a good diff utility would identify it as cosmetic changes to the source.

It doesn’t end here. A really smart diff program should also show you refactoring changes like method extraction. It should be able to predict that a new method has been extracted out of an existing method and also display the locations where this refactoring has been applied. Such a diff utility would be a boon to developers.

We are trying to develop a program which performs a few of the above mentioned ideas. It seems to be an extremely challenging task. We are making very slow progress with it, but progress nevertheless. Any help with this is more than welcome.

Tuesday, January 04, 2005

Lazy Loading

I am currently on a project that deals with Leases and Loans. It’s a really big project with about 60 people working on it. The customer would use this product to create thousands of organizations, leases, loans etc. and millions of assets, payments, charges etc. Going by the scale of the application, it should be apparent that performance would be a bottleneck. Yes it is !!
One of the most complicated screens in the application is the LeaseSchedule Screen. It contains 14 tabs and more than a hundred widgets. With all the SQL queries optimized, it still takes about 13 seconds just to bring up the screen !! The analysts want the screen to be loaded within 5 seconds. Now that’s asking for too much, right?

Hari, Saket and I decided to work on this card. Looking at the server console, we found out that it took 4 seconds to execute one main query where it creates the screen’s model. We concluded that we needed to tame this beast. Looking at the code, we saw that the screen initializes the model and then draws the GUI, populating the widgets with the data obtained from the model. Seems normal eh?
Well, we didn’t think so. We wanted to render the GUI independent of the model. This is where the idea of lazy loading came in. Firstly, we removed the use of the model in all the UI methods. We then initialized all the dependant models separately and collated them into a separate thread. Now, the UI would render separately and at the same time, the models would be created in another thread. With these changes the screen now loads in 2 seconds !! It actually loads in 3 stages which is clearly visible.
  1. The GUI is rendered with all the widgets, without any data.
  2. The data obtained from the model is populated into these widgets.
  3. The security features are applied to every widget.

The total time taken for the screen to be usable is still over 10 seconds, but the UI is rendered within 2 seconds. The user can now get to see the screen immediately, instead of waiting hopelessly without any visible response to the mouse/key events. I strongly recommend this approach for screens which need to display a lot of data.
But then came the final twist. We spoke to the client, telling him about the what we had achieved. He was very much impressed, but asked us not to implement this feature as of now, coz he perceived quite a few bugs to creep in due to these changes. Since we are very close to the end of the release, he told us that this would not be the appropriate time to incorporate these changes. We were told to document the approach, and probably implement it in the beginning of the next release.
After doing all this, it’s disheartening to revert all the changes. But I did learn quite a lot while doing this.

Sunday, January 02, 2005

Happy New Year

A rose from my neighbour's garden.

First and foremost... Wish you all a Happy and Prosperous New Year. Well, I am back to blogging. I used to blog at LiveJournal before, but I discontinued it coz I was bored of it. So that brings us to the obvious question -- what's this blog gonna be about ?
Well, I really dunno what I am gonna post out here. I guess it would be about my crazy ideas, programming, 3D games, my new interests, stocks/shares and ways of making money :-) , photography , blah, blah ...