Head.SmackOnTable();

Contains Nuts.

I am quite worried about the standard of coding these days

without comments

Ok, this is going to make me sound like a really old fart, which im not! Honest!

I was reading the blog of a Microsoft developer, someone whos team owns the Framework Design Guidelines, someone who worked on the VS Code Analysis team, and worked on FxCop.

Sample from davesbox.com

He then later states:

Comment from DavesBox.com

Im sorry, but WHAT THE F**K? Your not a fan of defensive coding, but you want us to do it in framework classes? With your code sample above, if label is null, guess what happens to your code? You may not like defensive coding, so you are going to assume that all of your code samples will work?

SetLabelTextIfNotEmpty(null);
SetLabelTextIfNotEmpty(Label1);  // No instance

Please tell me how your code will react to this? I guarentee that it will throw a null reference exception, because, well im passing in null to your method!

ALWAYS CHECK FOR NULL!

Im sure this is a minor lapse on your part, Dave, and im sure your code does not usually reflect this – if we had someone on my team, coding like this, I would either insist they change the way they code, or I would shift them off my team. Not checking for simple things, like null, is a major lapse in coding. You simply cannot guarentee that it will not be null, and wishfull thinking and happy thoughts arnt going to change it.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DotNetKicks
  • DZone

Written by Monty

November 18th, 2008 at 1:51 pm

Leave a Reply