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 fee 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.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.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 fee 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 fee 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 fee 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 fee 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 fee 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.