Readability on AL Guidelineshttps://alguidelines.dev/bcbestpractices/readability/Recent content in Readability on AL GuidelinesHugo -- gohugo.ioen-usbegin as an 'After Word'https://alguidelines.dev/bcbestpractices/readability/begin-as-an-afterword/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/begin-as-an-afterword/<Created by Microsoft, Described by waldo> Description When begin follows then, else, do, it should be on the same line, preceded by one space character. Bad code if ICPartnerRefType = ICPartnerRefType::"Common Item No." then begin ... end; Good code if ICPartnerRefType = ICPartnerRefType::"Common Item No." then begin ... end; Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.Begin-End - Compound Onlyhttps://alguidelines.dev/bcbestpractices/readability/begin-end/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/begin-end/<Created by Microsoft, Described by waldo> Only use begin..end to enclose compound statements. Bad code if FindSet() then begin repeat ... until next() = 0; end; Good code if FindSet() then repeat ... until next() = 0; Bad code if IsAssemblyOutputLine then begin TestField("Order Line No.", 0); end; Good code if IsAssemblyOutputLine then TestField("Order Line No.", 0); Exception // Except for this case if X then begin if Y then //DO SOMETHING; end else (not X) Discussions You can find discussions on all “Best Practices” here.Binary Operator to Start Linehttps://alguidelines.dev/bcbestpractices/readability/binary-operator-line-start/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/binary-operator-line-start/<Created by Microsoft, Described by waldo> Description Do not start a line with a binary operator. Bad code "Quantity to Ship" := Quantity - "Quantity Shipped" Good code "Quantity to Ship" := Quantity - "Quantity Shipped" Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.CASE Action on next linehttps://alguidelines.dev/bcbestpractices/readability/case-actions/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/case-actions/<Created by Microsoft, Described by waldo> Description A CASE action should start on a line after the possibility. Bad code case Letter of 'A': Letter2 := '10'; 'B': Letter2 := '11'; end; Good code case Letter of 'A': Letter2 := '10'; 'B': Letter2 := '11'; end; Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.Comment Spacinghttps://alguidelines.dev/bcbestpractices/readability/comments-spacing/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/comments-spacing/<Created by Microsoft, Described by waldo> Description Always start comments with // followed by one space character. Bad code RowNo += 1000; //Move way below the budget Good code RowNo += 1000; // Move way below the budget Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.end else pairhttps://alguidelines.dev/bcbestpractices/readability/end-else-pair/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/end-else-pair/<Created by Microsoft, Described by waldo> Description The end else pair should always appear on the same line. Bad code if OppEntry.Find('-') then if SalesCycleStage.Find('-') then begin ... end else begin ... end; Good code if OppEntry.Find('-') then if SalesCycleStage.Find('-') then begin ... end else begin ... end; Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.Keyword Pairs - Indentationhttps://alguidelines.dev/bcbestpractices/readability/keyword-pairs-indentation/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/keyword-pairs-indentation/<Created by Microsoft, Described by waldo> Description The if..then pair, while..do pair, and for..do pair must appear on the same line or the same level of indentation. If possible, you can align the lines it is even much more readable. Bad code if (x = y) and (a = b) then Good code if (x = y) and (a = b) then Discussions You can find discussions on all “Best Practices” here.Line Start Keywordshttps://alguidelines.dev/bcbestpractices/readability/line-start-keywords/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/line-start-keywords/<Created by Microsoft, Described by waldo> Description The end, if, repeat, for, while, else and case statement should always start a line. Bad code if IsContactName then ValidateContactName() else if IsSalespersonCode then ValidateSalespersonCode() else if IsSalesCycleCode then ValidatSalesCycleCode(); Good code if IsContactName then ValidateContactName() else if IsSalespersonCode then ValidateSalespersonCode() else if IsSalesCycleCode then ValidatSalesCycleCode(); Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.Lonely Repeathttps://alguidelines.dev/bcbestpractices/readability/lonely-repeat/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/lonely-repeat/<Created by Microsoft, Described by waldo> Description The repeat statement should always be alone on a line. Bad code if ReservEntry.FindSet() then repeat Good code if ReservEntry.FindSet() then repeat Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.Named Invocationshttps://alguidelines.dev/bcbestpractices/readability/named-invocations/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/named-invocations/<Created by Microsoft, Described by waldo> Description When calling an object statically use the Object Name, not the Object Id. Bad code Page.RunModal(525, SalesShptLine); Good code Page.RunModal(Page::"Posted Sales Shipment Lines", SalesShptLine); Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.One Statement Per Linehttps://alguidelines.dev/bcbestpractices/readability/one-statement-per-line/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/one-statement-per-line/<Created by Microsoft, Described by waldo> Description A line of code should not have more than one statement. Bad code if OppEntry.Find('-') then exit; Good code if OppEntry.Find('-') then exit; Bad code TotalCost += Cost; TotalAmt += Amt; Good code TotalCost += Cost; TotalAmt += Amt; Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.Separate if and elsehttps://alguidelines.dev/bcbestpractices/readability/separate-if-and-else/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/separate-if-and-else/<Created by Microsoft, Described by waldo> Description if and else statements should be on separate lines. Bad code if Atom = '\>' then HasLogicalOperator := true else begin ... end; Good code if Atom = '\>' then HasLogicalOperator := true else begin ... end; Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.Spacing Binary Operatorshttps://alguidelines.dev/bcbestpractices/readability/spacing-binary-operators/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/spacing-binary-operators/<Created by Microsoft, Described by waldo> Description There must be exactly one space character on each side of a binary operator such as = + - AND OR =. The parameter comma operator however, should have a space after the comma. Bad code "Line Discount %" := "Line Discount Amount"/"Line Value"*100; Good code "Line Discount %" := "Line Discount Amount" / "Line Value" * 100; Bad code StartDate := CalcDate('<+'+Format(Days+i)+'D\>',StartDate); Good code StartDate := CalcDate('<+' + Format(Days + i) + 'D\>', StartDate); Bad code StartDate:=0D; // Initialize Good code StartDate := 0D; // InitializeSuggested Abbreviationshttps://alguidelines.dev/bcbestpractices/readability/suggested-abbreviations/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/suggested-abbreviations/<Created by Microsoft, Described by waldo> Description Whenever possible, do not use abbreviations in variables, functions and objects names. If there is no other choice, then use the suggestions below. word Abbreviation absence Abs account Acc accounting Acc accumulated Accum action Act activity Activ additional Add address Addr adjust Adj adjusted Adjd adjustment Adjmt agreement Agrmt allocation Alloc allowance Allow alternative Alt amount Amt amounts Amts answer Ans applies Appl application Appln arrival Arriv assembly Asm assemble to order ATO assignment Assgnt associated Assoc attachment Attmt authorities Auth automatic Auto availability Avail average Avg ba db.Unnecessary 'else'https://alguidelines.dev/bcbestpractices/readability/unnecessary-else/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/unnecessary-else/<Created by Microsoft, Described by waldo> Description else should not be used when the last action in the then part is an exit, break, skip, quit, error. Bad code procedure SomeProcedure() begin if IsAdjmtBinCodeChanged() then Error(AdjmtBinCodeChangeNotAllowedErr, ...) else Error(BinCodeChangeNotAllowedErr, ...); end; Good code procedure SomeProcedure() begin if IsAdjmtBinCodeChanged() then Error(AdjmtBinCodeChangeNotAllowedErr, ...) Error(BinCodeChangeNotAllowedErr, ...); end; Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.Unnecessary true/falsehttps://alguidelines.dev/bcbestpractices/readability/unnecessary-truefalse/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/unnecessary-truefalse/<Created by Microsoft, Described by waldo> Description Do not use true or false keywords unnecessarily if the expression is already an logical expression. Bad code if IsPositive() = true then Good code if IsPositive() then Bad code if Complete <> true then Good code if not Complete then Discussions You can find discussions on all “Best Practices” here. If you don’t find the discussion of this guideline, please feel free to create a new one with the same title as this article.Variable Naminghttps://alguidelines.dev/bcbestpractices/readability/variable-naming/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/variable-naming/<Created by Microsoft, Described by waldo> Description Variables that refer to a AL object must contain the objects name, abbreviated where necessary. A variable must begin with a capital letter. Blanks, periods, and other characters (such as parentheses) that would make quotation marks around a variable necessary must be omitted. If a variable is a compound of two or more words or abbreviations, each word or abbreviation should begin with a capital letter.Variables Declarations Orderhttps://alguidelines.dev/bcbestpractices/readability/variables-declarations-order/Mon, 01 Jan 0001 00:00:00 +0000https://alguidelines.dev/bcbestpractices/readability/variables-declarations-order/<Created by Microsoft, Described by waldo> Description Variables declarations should be ordered by type. In general, object and complex variable types are listed first followed by simple variables. The order should be: Record Report Codeunit XmlPort Page Query Notification BigText DateFormula RecordId RecordRef FieldRef FilterPageBuilder (Ref: Microsoft Docs) Bad code StartingDateFilter: Text; Vendor: Record Vendor; Good code Vendor: Record Vendor; StartingDateFilter: Text; Discussions You can find discussions on all “Best Practices” here.