Click here to Skip to main content
14,635,332 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
Mark_Wallace15-Feb-19 12:53
MemberMark_Wallace15-Feb-19 12:53 
GeneralRe: Multiple returns from methods or clean code flow Pin
Tim Deveaux15-Feb-19 13:26
MemberTim Deveaux15-Feb-19 13:26 
AnswerRe: Multiple returns from methods or clean code flow Pin
Marc Clifton15-Feb-19 13:08
mvaMarc Clifton15-Feb-19 13:08 
GeneralRe: Multiple returns from methods or clean code flow Pin
BillWoodruff19-Feb-19 14:11
mveBillWoodruff19-Feb-19 14:11 
AnswerRe: Multiple returns from methods or clean code flow Pin
charlieg15-Feb-19 17:21
Membercharlieg15-Feb-19 17:21 
AnswerRe: Multiple returns from methods or clean code flow Pin
Member 916705717-Feb-19 20:42
MemberMember 916705717-Feb-19 20:42 
AnswerRe: Multiple returns from methods or clean code flow Pin
Delphi.7.Solutions17-Feb-19 21:52
MemberDelphi.7.Solutions17-Feb-19 21:52 
GeneralRe: Multiple returns from methods or clean code flow Pin
Member 798912218-Feb-19 0:34
MemberMember 798912218-Feb-19 0:34 
The first person to use the term "clean flow" has the definition right to the term Smile | :)

My experience is that prohibiting return (and continue and break) easily ruins that "clean flow". The clean flow should be for the normal, standard, expected behaviour. If something unexpected occurs, or some special case appears, you should handle it (as far as required) and get out of there! You shouldn't clutter up the rest of the function code with error flags and statuses pertaining to a special condition that was handled much higher up, serving only to skip the rest of the function code. That messes up the rest of the function code.

"Then you should raise an exception", some says. That's just another way of returning prematurely; it does not ensure a single point of exit. Besides, the situation is not necessarity exceptional, it may be simply detecting that there is nothing more to be done. Program flow by exceptions is certainly no clean code flow.
GeneralRe: Multiple returns from methods or clean code flow Pin
Delphi.7.Solutions18-Feb-19 3:30
MemberDelphi.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
MemberDavyd McColl17-Feb-19 22:18 
AnswerRe: Multiple returns from methods or clean code flow Pin
_WinBase_17-Feb-19 22:36
Member_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
Member 798912218-Feb-19 0:21
MemberMember 798912218-Feb-19 0:21 
AnswerRe: Multiple returns from methods or clean code flow Pin
Jeroen_R18-Feb-19 1:38
MemberJeroen_R18-Feb-19 1:38 
AnswerRe: Multiple returns from methods or clean code flow Pin
Michael Breeden18-Feb-19 2:00
MemberMichael Breeden18-Feb-19 2:00 
AnswerRe: Multiple returns from methods or clean code flow Pin
Peter R. Fletcher18-Feb-19 3:18
MemberPeter R. Fletcher18-Feb-19 3:18 
AnswerRe: Multiple returns from methods or clean code flow Pin
obermd18-Feb-19 4:30
Memberobermd18-Feb-19 4:30 
AnswerRe: Multiple returns from methods or clean code flow Pin
SpiritualMadMan18-Feb-19 4:54
MemberSpiritualMadMan18-Feb-19 4:54 
AnswerRe: Multiple returns from methods or clean code flow Pin
sickfile18-Feb-19 5:15
Membersickfile18-Feb-19 5:15 
AnswerRe: Multiple returns from methods or clean code flow Pin
TylerMc00718-Feb-19 5:52
MemberTylerMc00718-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
mveBillWoodruff19-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
MemberSeattleC++18-Feb-19 12:13 

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.