If not find then exit #253
Replies: 3 comments 5 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.
-
|
*nb: moved comment into separate comment to avoid mixed conversation |
Beta Was this translation helpful? Give feedback.
-
|
Ok, I see a valid point in early exit strategy, but my original question was not really about that but what @KOTRET adress above. VS I see no reason for the begin..end block |
Beta Was this translation helpful? Give feedback.
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