Click here to Skip to main content
15,897,519 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.

 
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 
I had to write some incredibly complicated business rules.
Imagine that we charge a 3% fee.
But there are like 19 situations where the fee is either more or less than that fee.
The fees are also relative to that 3% fee, which is customer specific.

I thought long and hard about how to write this to clarify the businesses intent, and used an infinite loop Smile | :) to avoid the return, but I also had to have a STRING indicating which rule was applied for logging, as well as to generate the invoice.
  while (true) {
  // Comment Describing Primary Condition 1
  if (condition1) {set %; set sMsg; break}

  // Comment Describing Primary Condition 2
  if (condition2) {set %; set sMsg; break}

  // Calculate complex logic...

  break; // prevent a loop
  }
  logIt("Rate Calculation",sMsg, % as string);
  setup return variables
  return;
}

The upside of this code was that the comments, and the FLOW were ratified 3 times by the business side. The code went into production 20 years ago, and was never modified.

Is this similar to the "many returns"? Yes, in a big way. There are many exits from the loop, but it captures the flow and priority perfectly. In fact, there was a decent amount of pre-loop setup code that calculated pieces to make the conditions make sense and be readable to the business people.

While I am HUGE on coding standards and code reviews. There are ALWAYS unique coding situations where I will gladly throw them all out the window to produce Highly Provable code that is easy to process and find errors in!
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 
GeneralRe: Thought of the Day Pin
dandy7215-Feb-19 5:36
dandy7215-Feb-19 5:36 
GeneralRe: Thought of the Day Pin
  Forogar  15-Feb-19 5:37
professional  Forogar  15-Feb-19 5:37 
GeneralRe: Thought of the Day Pin
Rajesh R Subramanian15-Feb-19 9:15
professionalRajesh R Subramanian15-Feb-19 9:15 
GeneralRe: Thought of the Day Pin
dandy7216-Feb-19 5:53
dandy7216-Feb-19 5:53 
GeneralRe: Thought of the Day Pin
Rajesh R Subramanian18-Feb-19 1:24
professionalRajesh R Subramanian18-Feb-19 1:24 
GeneralRe: Thought of the Day Pin
megaadam15-Feb-19 5:42
professionalmegaadam15-Feb-19 5:42 
GeneralRe: Thought of the Day Pin
jeron115-Feb-19 6:11
jeron115-Feb-19 6:11 
GeneralRe: Thought of the Day Pin
lopatir15-Feb-19 6:28
lopatir15-Feb-19 6:28 
GeneralRe: Thought of the Day Pin
jeron115-Feb-19 6:33
jeron115-Feb-19 6:33 
GeneralRe: Thought of the Day Pin
Mike Hankey15-Feb-19 7:47
mveMike Hankey15-Feb-19 7:47 
GeneralRe: Thought of the Day Pin
DRHuff15-Feb-19 10:27
DRHuff15-Feb-19 10:27 
GeneralToday is a good day Pin
Sander Rossel15-Feb-19 4:07
professionalSander Rossel15-Feb-19 4:07 
GeneralRe: Today is a good day Pin
Mark Parity15-Feb-19 4:24
Mark Parity15-Feb-19 4:24 
GeneralRe: Today is a good day Pin
Sander Rossel15-Feb-19 5:21
professionalSander Rossel15-Feb-19 5:21 

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.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   134 votes