Monday, February 11, 2008

The Uni-error code!

Its ironic for someone who taught Computer Programming and that too C++ to be struggling with errors in a C++ code, but that's my fate now in MS! Wait a minute!! Did I say errors?? Oh no not atall! Our DBI code gives just one error...SEGMENTATION FAULT!

Programs I seriously think are like two year olds. You have to coax them into getting up and working. Even then they may do just what they want instead of doing what you want them to do. If you persuade them too much then they will sulk and refuse to compile. And as I just said before, if you really get them mad at you, they might just compile but when they run they'll give you the dreaded segmentation fault!!

For those who haven't yet entered the murky catacombs of C++, segmentation fault is that universal name given to all sorts of pointer problems. Perhaps ye gods who made the computer and its systems didn't want us mortals to understand all its secrets! But to get back to our uni-error, it crops up at unexpected places, it may show up on some systems and may not on others. It might come up once in a blue moon or once in a day or even once in a year. Sometimes it reveals itself to the customer but never graces the developer with its divine presence. So to all cricket enthusiasts, ha! You may have a lot of ways to get out in your game but we coders have a lot more ways to generate a segmentation fault in ours!!

Coming back to our code, like I described before, theres only one way to understand a two year old. Make friends with it. Give it candies and chocolates. Talk to it in its baby-language. And perhaps it will warm up to you and begin following your instructions. Same goes for programs. You have to give it a debugger like GDB (or give it to the debugger rather!), talk to it in terms of memory leaks and uninitialized pointers, make friends with it with debugging cout statements and comments and it will warm up to you unless it really hates you and absolutely refuses to run!

Thats what we tried with out DBI code and its up and running for now. but again, all this is just to understand one two-year old (or code) and when the next one comes along, we are compelled to agree "Oh segmentation fault, thou shalt rule the minds of programmers forever!!"

Just b4 I sign off here's something to cheer all you coders trapped in segmentation faults... http://www-users.cs.york.ac.uk/susan/joke/haiku.htm