Datatypes are difficult. So is typecasting. And if you don't understand one, you probably don't get the other either. And if you don't get either, you should probably give up on writing code and find a new career. You may get a slight pay cut for doing so, but at least you can quit spending half your salary on all those expensive reconstruction surgeries every time your coworkers go on a cluebat rampage against your face. And your coworkers will certainly appreciate not having to lose brain cells to your poorly-written functions, like these submitted by Kevin.

private int GetClassRoomArea(Int32 StudentCount) {
  return ((int)(Convert.ToInt32(StudentCount)) * 2 / 1000); 
} 

Either the author of this function was deathly afraid that his int would grow up into something else, or he was clueless. It takes an int, converts it to an int, and then casts it to an int. Unless he's dealing with a really quirky compiler written for free by a team of unpaid interns who don't understand the difference between a signed integer and a banana, I would place my vote on clueless.

Here's another such function:

private string GetPercentage(Int32 EducationTotal) {
  return (string)((double)(Convert.ToInt32(EducationTotal)) / Total * 100).ToString("N2");
}

This one also converts the int to an int, then inexplicably casts it to a double. This seems to be in error, so the author used integer division to change it back into an int. Finally, because ToString() is such a poorly-documented and poorly-understood call and you never know what type it'll give you, he casts its result to a string.

Upon reading these, I imagine that Kevin felt the death of at least a few more of his brain cells and tightened his grip on his trusty cluebat. Half an hour later, he returns to his desk to rewrite the offending code into something more sane. Meanwhile, the company intercom chimes "Cleanup on Floor 3, Cubicle 12. Cleanup on Floor 3, Cubicle 12."

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!