Friday, June 24, 2005

On hyping things up...

Learning to hype about what you do is a very useful thing. At the same time it is an art which is fairly hard to learn. I realise this everytime I see my resume :). So in an effort to someday have a better sounding resume, I am thinking about this fine skill. Here are some examples to get started:
  1. "I have been adding 'fault tolerance' in my code"

    Any unskilled person will think that you are referring to some failover of service instances or redundancy or some such thing. But if you are creative you can use the same statement for plain old 'error handling' :) where you expect something (server is open at port x) and it does not happen (it is down) and you handle it as appropriate. Contrast the above statement with "I fixed bug#xxxx where the client hung when the server was not up"

  2. I am working on loosely coupled distributed systems.

    This feels like you are building something like google search engine or amazon book store. Did it ever occur to you that this applies to building a client console (webservice or dcom) to any service.
Putting 1 and 2 together, you should not hesitate to say that you build "Distributed fault tolerant systems" as part of your daily job :)

Friday, June 17, 2005

Dotnet gotchas - 3

Synchronized collections are not synchronized on what you think they are, if you are coming from the java world. Consider the following piece of code:

Hashtable ht = Hashtable.Synchronized(new Hashtable());

addToTable(object o )
{
ht.Add(o, o);
}

processAll()
{
lock(ht)
{
// enumerate and do something with them. hold lock so that
// someone does not modify while you are enumerating...
}
}
The above code is incorrect since synchronised hashtables sync on an internal object called SyncRoot and not on the object itself!!

Thursday, June 16, 2005

Crores and companies...

Recently I took a ride home from one of my dad's friend who happens to be an industrialist. As is the case with these elderly people, he started talking about life and money. He started with how so many people have made a lot of money in real estate in the hi-tech area and how he was a happier person than someone having 500 crores.

He wondered, "When all you need to live comfortably is 5 crores so why would anyone want more ? It is not as if these big people can even spend money - they have diabetes, bp, what not...! Most become obsessed with money and they dont even feel like spending on domestic help like a driver, gardener, cook, assistant etc.. but the person who makes even 1 crore/year in a company - like a General Manager is much happier since he automatically gets all the perks mentioned above in addition to staying in 5 star hotels whenever he goes on official visits ......"

The scale at which he was talking felt pretty wierd to me :). It looks like everyone, be it a govt employee, an IT professional or an industrialist, thinks they belong to the lower middle class :).

Something equally wierd happened at office today, but that is a post for a later time...

Friday, June 10, 2005

Dotnet gotchas - 2

XML (ha ha ha, it had to come somewhere isn't it) serialization is not symmetric when you have custom collections (.net 1.1). Say u have a class called (psudocode only..)
public class Dummy
{
[XmlElement("Name")]
public string a = "dummy";

[XmlArray("Things")]
public MyCollection col = null;

public Ha(){}
}
When you create an instance of a class and deserialize it you get an xml like
<Dummy>
<Name>dummy</Name>
</Dummy>
Now when you deserialize it you expect to get a equivalent object obj1 with a initialized to "dummy" and col to null. However, what you actually get for col field is an "empty collection" object!! So if you are testing your webservice (this joke had to come somewhere too :) ), a save retrieve sequence will get you an object which is slightly different from what you are expecting (it is a different issue that the webservice can never see null since the transport is xml serialization)!

Thursday, June 09, 2005

Dotnet gotchas - 1

So I have finally moved into the new team and it happens to be milestone exit time.. and in all their magnanimity they handled me several dumps to look at :). The next few blogs will be about what I have learnt this last week...(assuming that we exit this week).

Contrary to popular opinion and appearances - Thread aborts can abort finally blocks in .net 1.1 !! This is actually documented in msdn! so code like

lock(this)
{
blah...
}
can fail to release the lock in case of thread abort leaving an orphaned SyncBlk. You can expect the rest of the app worker threads to slowly hit this region and hang.

What makes this even more interesting is that web services extensions (wse) merrily abort threads on timeouts :)