Sunday, November 29, 2009

Karma in Computer Science and the Story of Abbas

For those who don't know what Karma is, here it is in my own words.

In religion if you did something bad, something bad will happen to you. If you did something good something good will happen to you based on your actions. In Islam we call this العدالة الإلهية or the Ultimate justice, In Buddhism its called Karama.

Scientifically, If you do something good or you did something bad there is an amount of energy that you release whether positive or negative, this amount of energy someday will come back to you (the source) .

The Unfortunate Driver
Let me tell you a story about how Karma does its magic.

One day an employee was late for work in the morning, so he drove fast and start overtaking a car in front of him. The other driver was angry, and he also started to overtake the next car, the next driver seeing this overtake the next car.. and so on.

In the end of the day our employee leaves his work. On his way to the parking he was hit by an overtaking car, a car from the same series he created earlier this day.

Karma will find you.

Abbas and the Process.Kill()
OK. Now can this apply this to computer science. Let me tell you a story that will explain the whole thing.

Once upon a time there was a developer lets call him Abbas. Abbas was a brilliant developer, he does his tasks quickly and he rarely says I don't know. One day Abbas encountered a weird error upon closing one of the application. He didn't know the source of the error and after half an hour of searching he gave up and decided to apply a quick fix by simply kill the process on the exit this way .NET garbege collector won't have the time to show this error. It WORKED.

The clients were SO happy the damned error upon closing the application disappeared. The application has been submitted, and the maintenance period finished.

One day one of the clients reported that no matter what edits and changes he apply to the application, they are not saved. So the client IT team started to do their research and stumbled upon a piece of code that kills the application process clearly marked with a comment -Abbas and dated. It appears that killing the process prevented the application from running the On_Close event on which the saving of the data is being done.

Karma found Abbas.