Click here to Skip to main content
15,890,438 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Multiple returns from methods or clean code flow Pin
kalberts18-Feb-19 0:34
kalberts18-Feb-19 0:34 
GeneralRe: Multiple returns from methods or clean code flow Pin
Delphi.7.Solutions18-Feb-19 3:30
Delphi.7.Solutions18-Feb-19 3:30 
GeneralRe: Multiple returns from methods or clean code flow Pin
Richard Deeming18-Feb-19 2:08
mveRichard Deeming18-Feb-19 2:08 
AnswerRe: Multiple returns from methods or clean code flow Pin
Davyd McColl17-Feb-19 22:18
Davyd McColl17-Feb-19 22:18 
AnswerRe: Multiple returns from methods or clean code flow Pin
_WinBase_17-Feb-19 22:36
_WinBase_17-Feb-19 22:36 
AnswerRe: Multiple returns from methods or clean code flow Pin
megaadam17-Feb-19 22:47
professionalmegaadam17-Feb-19 22:47 
AnswerRe: Multiple returns from methods or clean code flow Pin
kalberts18-Feb-19 0:21
kalberts18-Feb-19 0:21 
AnswerRe: Multiple returns from methods or clean code flow Pin
Jeroen_R18-Feb-19 1:38
Jeroen_R18-Feb-19 1:38 
Forogar wrote:
This caused horribly messy code

Nah. Earlier return is both much more readable and more logical too.

More readable: you don't have to skip around when following a given execution path, you just follow it to its return.

More logical: you don't have to keep anything you don't need anymore in mind. When the function is done with it, it's returned and doesn't add to the cognitive load anymore.

The time when single exit point was a 'good practice' was, IIRC, during the structured programming days, as an antidote to goto statements.

Forogar wrote:
introduces an execution statement (return) on the same line as the "if" which is bad coding practice

Huh? why? It's only styling. I would avoid having it under the if without brackets, because that's confusing sometimes, but on the same line? No problems.
AnswerRe: Multiple returns from methods or clean code flow Pin
Michael Breeden18-Feb-19 2:00
Michael Breeden18-Feb-19 2:00 
AnswerRe: Multiple returns from methods or clean code flow Pin
Peter R. Fletcher18-Feb-19 3:18
Peter R. Fletcher18-Feb-19 3:18 
AnswerRe: Multiple returns from methods or clean code flow Pin
obermd18-Feb-19 4:30
obermd18-Feb-19 4:30 
AnswerRe: Multiple returns from methods or clean code flow Pin
SpiritualMadMan18-Feb-19 4:54
SpiritualMadMan18-Feb-19 4:54 
AnswerRe: Multiple returns from methods or clean code flow Pin
Martin ISDN18-Feb-19 5:15
Martin ISDN18-Feb-19 5:15 
AnswerRe: Multiple returns from methods or clean code flow Pin
TylerMc00718-Feb-19 5:52
TylerMc00718-Feb-19 5:52 
AnswerRe: Multiple returns from methods or clean code flow Pin
MSBassSinger18-Feb-19 7:55
professionalMSBassSinger18-Feb-19 7:55 
GeneralRe: Multiple returns from methods or clean code flow Pin
BillWoodruff19-Feb-19 15:28
professionalBillWoodruff19-Feb-19 15:28 
GeneralRe: Multiple returns from methods or clean code flow Pin
MSBassSinger19-Feb-19 15:34
professionalMSBassSinger19-Feb-19 15:34 
AnswerRe: Multiple returns from methods or clean code flow Pin
SeattleC++18-Feb-19 12:13
SeattleC++18-Feb-19 12:13 
AnswerRe: Multiple returns from methods or clean code flow Pin
frazGJF18-Feb-19 18:08
frazGJF18-Feb-19 18:08 
AnswerRe: Multiple returns from methods or clean code flow Pin
BillWoodruff19-Feb-19 0:45
professionalBillWoodruff19-Feb-19 0:45 
AnswerRe: Multiple returns from methods or clean code flow Pin
S.Donovan19-Feb-19 3:03
professionalS.Donovan19-Feb-19 3:03 
AnswerRe: Multiple returns from methods or clean code flow Pin
Kirk 1038982119-Feb-19 7:32
Kirk 1038982119-Feb-19 7:32 
GeneralThought of the Day Pin
OriginalGriff15-Feb-19 4:50
mveOriginalGriff15-Feb-19 4:50 
GeneralRe: Thought of the Day Pin
User 483504715-Feb-19 5:05
User 483504715-Feb-19 5:05 
GeneralRe: Thought of the Day Pin
lopatir15-Feb-19 5:09
lopatir15-Feb-19 5:09 

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.