Click here to Skip to main content
15,886,780 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: What this 'null' check doing here... Pin
David C. Thompson10-Jul-13 3:05
David C. Thompson10-Jul-13 3:05 
GeneralRe: What this 'null' check doing here... Pin
Mohammed Hameed10-Jul-13 19:39
professionalMohammed Hameed10-Jul-13 19:39 
GeneralRe: What this 'null' check doing here... Pin
David C. Thompson10-Jul-13 20:51
David C. Thompson10-Jul-13 20:51 
GeneralRe: What this 'null' check doing here... Pin
Mark Starr10-Jul-13 4:25
professionalMark Starr10-Jul-13 4:25 
GeneralRe: What this 'null' check doing here... Pin
KP Lee10-Jul-13 20:19
KP Lee10-Jul-13 20:19 
GeneralRe: What this 'null' check doing here... Pin
Mark Starr11-Jul-13 5:18
professionalMark Starr11-Jul-13 5:18 
GeneralRe: What this 'null' check doing here... Pin
KP Lee15-Jul-13 20:32
KP Lee15-Jul-13 20:32 
GeneralRe: What this 'null' check doing here... Pin
Mark Starr16-Jul-13 5:20
professionalMark Starr16-Jul-13 5:20 
Not a prob, I was in fact, just starting the day, and clearly had too little coffee in my system to type, much less proof.

We had just been playing around with javascript to see what happens when you don't declare a variable versus when you declare it and don't assign a value - how it affects checking for undefined, not-undefined, null, etc. And, Yes, I typically write a lot more in T-SQL, but I also use VB, VB.NET, et al in my daily work - hence my disclaimer about not writing a lot of C#. I'm always careful when checking for nulls, so when I see comparison operator my hair stands up a bit.

Initially, to me, the code looked as though someone had somehow had a bad experience populating the list from using the "new List<employee>();" call, and so put in a safety-catch (if you will) to try again if necessary. Or, perhaps, the second part was already there, and someone later came along and added the first line... I'm sure they though it was right at the time. Who knows!

Thanks for the note KP. Cheers and happy coding,
Mark
GeneralRe: What this 'null' check doing here... Pin
GrumpyPants10-Jul-13 5:33
GrumpyPants10-Jul-13 5:33 
GeneralRe: What this 'null' check doing here... Pin
Mohammed Hameed10-Jul-13 19:35
professionalMohammed Hameed10-Jul-13 19:35 
GeneralRe: What this 'null' check doing here... Pin
RafagaX10-Jul-13 5:43
professionalRafagaX10-Jul-13 5:43 
GeneralRe: What this 'null' check doing here... Pin
Mohammed Hameed10-Jul-13 19:43
professionalMohammed Hameed10-Jul-13 19:43 
GeneralRe: What this 'null' check doing here... Pin
Michael Losinski10-Jul-13 5:59
Michael Losinski10-Jul-13 5:59 
GeneralRe: What this 'null' check doing here... Pin
Mohammed Hameed10-Jul-13 19:45
professionalMohammed Hameed10-Jul-13 19:45 
GeneralRe: What this 'null' check doing here... Pin
KP Lee10-Jul-13 21:01
KP Lee10-Jul-13 21:01 
GeneralRe: What this 'null' check doing here... Pin
Michael Losinski11-Jul-13 3:40
Michael Losinski11-Jul-13 3:40 
GeneralRe: What this 'null' check doing here... Pin
Nilesh Shahane10-Jul-13 8:07
Nilesh Shahane10-Jul-13 8:07 
GeneralRe: What this 'null' check doing here... Pin
Mohammed Hameed10-Jul-13 19:47
professionalMohammed Hameed10-Jul-13 19:47 
GeneralRe: What this 'null' check doing here... Pin
MainFrameMan_ALIVE_AND_WELL$$10-Jul-13 10:03
MainFrameMan_ALIVE_AND_WELL$$10-Jul-13 10:03 
GeneralRe: What this 'null' check doing here... Pin
Mohammed Hameed10-Jul-13 19:48
professionalMohammed Hameed10-Jul-13 19:48 
GeneralRe: What this 'null' check doing here... Pin
KP Lee10-Jul-13 21:13
KP Lee10-Jul-13 21:13 
GeneralRe: What this 'null' check doing here... Pin
Mohammed Hameed10-Jul-13 21:15
professionalMohammed Hameed10-Jul-13 21:15 
GeneralRe: What this 'null' check doing here... Pin
DarkChuky CR12-Jul-13 12:56
DarkChuky CR12-Jul-13 12:56 
GeneralRe: What this 'null' check doing here... Pin
Mohammed Hameed14-Jul-13 19:46
professionalMohammed Hameed14-Jul-13 19:46 
GeneralRe: What this 'null' check doing here... Pin
Chad3F13-Jul-13 19:17
Chad3F13-Jul-13 19:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.