Named return values or exit with local variable? #247
PeterConijn
started this conversation in
BC Patterns
Replies: 1 comment
-
|
I clearly prefer a named returned variable:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is something that has always irked me a bit.
Since version (look up version, red.) we have the ability to have named return values. I have, however, noticed that Microsoft seems to avoid using them, opting instead for exiting a local variable.
There is no pattern* for this at the moment, but which one is the advised preference?
*) This is not about using a named variable vs. exiting with a result directly (e.g. exit(not Customer.IsEmpty()). This is specifically when a variable is required: do we prefer a local variable or a named return value?
Named variable
Return local variable:
Note: I seem to recall @ajkauffmann once stating that one of the two is more memory-efficient. Perhaps that can be taken into account as well.
Beta Was this translation helpful? Give feedback.
All reactions