Case action on next line #90
Replies: 9 comments 13 replies
-
For even the long one-liners, I find it WAY more readable with the 2nd format. It also makes any multi-liner, begin/end, one stand out as a more complex scenario, and that adds instant value. |
Beta Was this translation helpful? Give feedback.
-
I am ok with any of the options but prefer option B. However my general rule is in such cases is and that I would write as a guideline: use AL formatter. I know it change from time to time and then the file is changed without any new code but I trust the formatter (I should not maybe but I can take that risk). |
Beta Was this translation helpful? Give feedback.
-
I prefer first option. But I wouldn't even mentioned if I see second option in the PR I'm reviewing, because is is personal preferences. |
Beta Was this translation helpful? Give feedback.
-
I prefer Visual Studio gracefully solve this case by letting us define Code Style settings : Adding some VSCode extension settings could be a good improvement |
Beta Was this translation helpful? Give feedback.
-
Actually I like both. First is more elegant and suits well when using begin...end - so if we have one option, I vote for the existing. |
Beta Was this translation helpful? Give feedback.
-
Neither, but rather this:
Yes, even for one liners. Then, if you need to add code to any of the cases, you will not need to add begin/end. |
Beta Was this translation helpful? Give feedback.
-
I've had too many issues with compound statements to teach myself to always use BEGIN/END even for one liners, and the only place I ever do is case statements. I would program it on single lines (and try to use function calls instead of programming the thing inside the case) and then the formatter would put them on separate lines. For case statements I don't have a clear preference, I think they are both very readable. Maybe the separate lines makes the case stand out a little more, so maybe that is preferable and why the formatter does it like that. |
Beta Was this translation helpful? Give feedback.
-
The first one, more readable IMO |
Beta Was this translation helpful? Give feedback.
-
I prefer the onliner, but when saving the AL Formatter will change it to the first example.. |
Beta Was this translation helpful? Give feedback.
-
Regarding: https://alguidelines.dev/bcbestpractices/readability/case-actions/
Personally, I'm not ok with this guideline. I know the AL formatter automatically is going to format to:
But for oneliners, I find this much more readable:
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions