Posts

Showing posts from April, 2008

Uninitalized variable

I have heard a lot about initializing variables and have wondered why so much is being said about it as long as the developer is going to use the variable sensibly, but i happened to work on a issue where a uninitialized variable (supposed to hold a proper enum value) was passed on to a function working on the following enum values, ----------------------------------------------------------------------------------------------------------------- [Code] enum property { NAME = 0, TELEPHONE, ADDRESS, E-MAIL, FAX, PAGER }; void act_on_property(int property_type) { switch(property_type) { case NAME : ... case TELEPHONE : ... case ADDRESS : ... case E-MAIL : ... case FAX : ... case PAGER : ... default : log ("invalid value"); } } ----------------------------------------------------------------------------------------------------------------- The problem was that the variable was a global one, having static storage class. In one p...

exception handling

Image
It is indeed worth the time spent in handling exceptions, an unhandled exception often exposes quite a lot of vital information, like the following one from a popular video downloading site, exposing the details of a database table,

Bug in Spider

Image
How am i supposed to finish the game? despite having good enough slots to complete the last set of cards :-( The deal should have been allowed when there aren't enough cards fill up the empty slots...