microsoft / alguidelines

Best Practices and Design Patterns for the AL Language
https://alguidelines.dev/
MIT License
131 stars 49 forks source link

CASE Action on next line #70

Closed waldo1001 closed 2 years ago

waldo1001 commented 2 years ago

Personally, I'm not really thrilled about this guideline. I find the "Bad Code" better readable than the "Good Code".

What do you guys think? And where should we discuss? LIke:

TheDoubleH commented 2 years ago

I HATE the 'Good code' version of this. I believe that it lessens readability.

I can see it, IF You have a BEGIN END inside the CASE Statement

    case SourceTableNo of
        DATABASE::Customer :
            Begin
              Customer.Get(SourceNo);
              Customer.Validate(Name, NewName);
              Customer.Modify(TRUE);
            End;
        DATABASE::Vendor :
            Begin
              Customer.Get(SourceNo);
              Customer.Validate(Name, NewName);
              Customer.Modify(TRUE);
           End;
       Else
           Error(TableNotSupportedErr);
   End;

I say we bring it up for discussion

JesperSchulz commented 2 years ago

Agree, in the case of one liners, the "bad code" example is preferable! Let's spawn a discussion based on this PR.

ajkauffmann commented 2 years ago

I like the one-liners too, but discussing it might not solve it. The autoformat feature in AL changes it to multiline code anyway. And what if the case statement is combining one-liners and multi-liners? Anyway, even if everybody agrees that oneliners are more readable, we still have to convince Microsoft to not autoformat the case statement. I think we should publish and have a separate discussion.

waldo1001 commented 2 years ago

I agree with @ajkauffmann - turning this guideline around will take some time. Today, the guideline is as described .. so let's open the discussion when this guideline is published.. ?