Click here to Skip to main content
15,891,607 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: Which code you suggest? Pin
ZurdoDev29-Jul-13 14:45
professionalZurdoDev29-Jul-13 14:45 
GeneralRe: Which code you suggest? Pin
Ravi Bhavnani30-Jul-13 5:05
professionalRavi Bhavnani30-Jul-13 5:05 
GeneralRe: Which code you suggest? Pin
ZurdoDev30-Jul-13 5:07
professionalZurdoDev30-Jul-13 5:07 
GeneralRe: Which code you suggest? Pin
Ravi Bhavnani30-Jul-13 5:10
professionalRavi Bhavnani30-Jul-13 5:10 
GeneralRe: Which code you suggest? Pin
ZurdoDev30-Jul-13 5:14
professionalZurdoDev30-Jul-13 5:14 
GeneralRe: Which code you suggest? Pin
Ravi Bhavnani30-Jul-13 5:26
professionalRavi Bhavnani30-Jul-13 5:26 
AnswerRe: Which code you suggest? Pin
Dave Kreskowiak25-Jul-13 4:49
mveDave Kreskowiak25-Jul-13 4:49 
AnswerRe: Which code you suggest? PinPopular
Ron Beyer25-Jul-13 4:53
professionalRon Beyer25-Jul-13 4:53 
I'm a fan of early exit, so I'd go with the first one (assuming that's what this post is about).

It doesn't really matter much in smaller routines like the one above, but when you have longer ones it can be difficult to follow retValue around the function to find out where you are really setting the return value. The first method is shorter because you can run a case through in your head without having to write down variables.

I think the question boils down to Early Exit versus Single Exit. There's a lot of debate on the merits of both so I think your answers are going to be somewhat distributed between them. I've yet to hear a debate for single exit that I agree with over the merits of early exit...
GeneralRe: Which code you suggest? Pin
ZurdoDev25-Jul-13 8:34
professionalZurdoDev25-Jul-13 8:34 
GeneralRe: Which code you suggest? Pin
Nicholas Marty25-Jul-13 23:06
professionalNicholas Marty25-Jul-13 23:06 
GeneralRe: Which code you suggest? Pin
Sentenryu26-Jul-13 0:55
Sentenryu26-Jul-13 0:55 
GeneralRe: Which code you suggest? Pin
ZurdoDev26-Jul-13 1:31
professionalZurdoDev26-Jul-13 1:31 
GeneralRe: Which code you suggest? Pin
Sentenryu26-Jul-13 3:53
Sentenryu26-Jul-13 3:53 
GeneralRe: Which code you suggest? Pin
AJC Software26-Jul-13 0:54
AJC Software26-Jul-13 0:54 
AnswerRe: Which code you suggest? PinPopular
CodeHawkz25-Jul-13 18:34
CodeHawkz25-Jul-13 18:34 
GeneralRe: Which code you suggest? Pin
Sentenryu26-Jul-13 1:03
Sentenryu26-Jul-13 1:03 
AnswerRe: Which code you suggest? Pin
BubingaMan25-Jul-13 21:10
BubingaMan25-Jul-13 21:10 
AnswerRe: Which code you suggest? Pin
Simon O'Riordan from UK25-Jul-13 22:26
Simon O'Riordan from UK25-Jul-13 22:26 
GeneralRe: Which code you suggest? Pin
Sentenryu26-Jul-13 1:05
Sentenryu26-Jul-13 1:05 
GeneralRe: Which code you suggest? Pin
Simon O'Riordan from UK26-Jul-13 1:21
Simon O'Riordan from UK26-Jul-13 1:21 
AnswerRe: Which code you suggest? Pin
vonb25-Jul-13 22:41
vonb25-Jul-13 22:41 
AnswerRe: Which code you suggest? Pin
Stefan_Lang26-Jul-13 0:09
Stefan_Lang26-Jul-13 0:09 
GeneralRe: Which code you suggest? Pin
Renzo Ciafardone27-Jul-13 17:00
Renzo Ciafardone27-Jul-13 17:00 
GeneralRe: Which code you suggest? Pin
Stefan_Lang28-Jul-13 22:00
Stefan_Lang28-Jul-13 22:00 
GeneralRe: Which code you suggest? Pin
Renzo Ciafardone29-Jul-13 14:25
Renzo Ciafardone29-Jul-13 14:25 

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.