If not find then exit #253
Anders-Ryden
started this conversation in
BC Best Practices
Replies: 1 comment 4 replies
-
|
I actually think this should really have been called Early Exit Early Exit The Point with this pattern is really to exit a function early, in order to avoid indented code.
I do not see that reference, but it really should be: if not Record.Findset() then
exit;
repeat
DoStuff(Record);
until Record.Next() = 0; |
Beta Was this translation helpful? Give feedback.
4 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.
Uh oh!
There was an error while loading. Please reload this page.
-
https://alguidelines.dev/docs/bestpractices/if-not-find-then-exit/
This rule suggest that we should check if the record is empty, and if so exit the code instead of checking for records and then looping.
This should give clearer code and reduce the number of ends and extra indentations.
should be replaced with
Only I have never written a loop like that, there is no need for the begin/end so I write it like this.
To my mind that is clearer.
I don't see the benefit here, I prefer to make positive code that runs all the way rather than negative code where you exit the code at various places along the way if that makes sense.
What are your thoughts?
Beta Was this translation helpful? Give feedback.
All reactions