From 6162a121be29649b70715ce2ebd37bbf8dc0e000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Br=C3=A4unlich?= Date: Thu, 5 May 2022 16:16:27 +0000 Subject: [PATCH 1/7] added caption for each example --- content/docs/BestPractices/begin-end/index.md | 12 ++++++++---- .../one-statement-per-line/index.md | 12 ++++++++---- .../spacing-binary-operators/index.md | 18 ++++++++++++------ .../unnecessary-truefalse/index.md | 12 ++++++++---- .../BestPractices/variable-naming/index.md | 18 ++++++++++++------ 5 files changed, 48 insertions(+), 24 deletions(-) diff --git a/content/docs/BestPractices/begin-end/index.md b/content/docs/BestPractices/begin-end/index.md index f92bf395..b0eb6867 100644 --- a/content/docs/BestPractices/begin-end/index.md +++ b/content/docs/BestPractices/begin-end/index.md @@ -8,7 +8,9 @@ _Created by Microsoft, Described by waldo_ Only use begin..end to enclose [compound statements](https://docs.microsoft.com/en-us/cpp/c-language/compound-statement-c?view=msvc-170#:~:text=A%20compound%20statement%20%28also%20called%20a%20%22block%22%29%20typically,appear%20at%20the%20head%20of%20a%20compound%20statement.). -## Bad code +## Example 1 + +### Bad code ```AL if FindSet() then begin @@ -18,7 +20,7 @@ if FindSet() then begin end; ``` -## Good code +### Good code ```AL if FindSet() then @@ -27,7 +29,9 @@ if FindSet() then until next() = 0; ``` -## Bad code +## Example 2 + +### Bad code ```AL if IsAssemblyOutputLine then begin @@ -35,7 +39,7 @@ if IsAssemblyOutputLine then begin end; ``` -## Good code +### Good code ```AL if IsAssemblyOutputLine then diff --git a/content/docs/BestPractices/one-statement-per-line/index.md b/content/docs/BestPractices/one-statement-per-line/index.md index 4bc36b72..822c05c1 100644 --- a/content/docs/BestPractices/one-statement-per-line/index.md +++ b/content/docs/BestPractices/one-statement-per-line/index.md @@ -10,26 +10,30 @@ _Created by Microsoft, Described by waldo_ A line of code should not have more than one statement. -## Bad code +## Example 1 + +### Bad code ```al if OppEntry.Find('-') then exit; ``` -## Good code +### Good code ```al if OppEntry.Find('-') then exit; ``` -## Bad code +## Example 2 + +### Bad code ```al TotalCost += Cost; TotalAmt += Amt; ``` -## Good code +### Good code ```al TotalCost += Cost; diff --git a/content/docs/BestPractices/spacing-binary-operators/index.md b/content/docs/BestPractices/spacing-binary-operators/index.md index 32902eae..e0bfaac8 100644 --- a/content/docs/BestPractices/spacing-binary-operators/index.md +++ b/content/docs/BestPractices/spacing-binary-operators/index.md @@ -10,37 +10,43 @@ _Created by Microsoft, Described by waldo_ 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 +## Example 1 + +### Bad code ```al "Line Discount %" := "Line Discount Amount"/"Line Value"*100; ``` -## Good code +### Good code ```al "Line Discount %" := "Line Discount Amount" / "Line Value" * 100; ``` -## Bad code +## Example 2 + +### Bad code ```al StartDate := CalcDate('<+'+Format(Days+i)+'D\>',StartDate); ``` -## Good code +### Good code ```al StartDate := CalcDate('<+' + Format(Days + i) + 'D\>', StartDate); ``` -## Bad code +## Example 3 + +### Bad code ```al StartDate:=0D; // Initialize ``` -## Good code +### Good code ```al StartDate := 0D; // Initialize diff --git a/content/docs/BestPractices/unnecessary-truefalse/index.md b/content/docs/BestPractices/unnecessary-truefalse/index.md index 2950736f..57d6864b 100644 --- a/content/docs/BestPractices/unnecessary-truefalse/index.md +++ b/content/docs/BestPractices/unnecessary-truefalse/index.md @@ -9,25 +9,29 @@ _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 +## Example 1 + +### Bad code ```al if IsPositive() = true then ``` -## Good code +### Good code ```al if IsPositive() then ``` -## Bad code +## Example 2 + +### Bad code ```al if Complete <> true then ``` -## Good code +### Good code ```al if not Complete then diff --git a/content/docs/BestPractices/variable-naming/index.md b/content/docs/BestPractices/variable-naming/index.md index 3ead389b..290174a0 100644 --- a/content/docs/BestPractices/variable-naming/index.md +++ b/content/docs/BestPractices/variable-naming/index.md @@ -16,37 +16,43 @@ Blanks, periods, and other characters (such as parentheses) that would make quot If a variable is a compound of two or more words or abbreviations, each word or abbreviation should begin with a capital letter. -## Bad code +## Example 1 + +### Bad code ```al WIPBuffer: Record "Job WIP Buffer" ``` -## Good code +### Good code ```al JobWIPBuffer: Record "Job WIP Buffer" ``` -## Bad code +## Example 2 + +### Bad code ```al Postline: Codeunit "Gen. Jnl.-Post Line"; ``` -## Good code +### Good code ```al GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; ``` -## Bad code +## Example 3 + +### Bad code ```al "Amount (LCY)": Decimal; ``` -## Good code +### Good code ```al AmountLCY: Decimal; From a15b53e3f6bd5133bf2ac8b4a517697ca8ac0927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vercaemst?= Date: Fri, 6 May 2022 09:00:32 +0200 Subject: [PATCH 2/7] Added Tips section with link to VS Code extension --- .../BestPractices/blank-lines-when-not-to-use/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content/docs/BestPractices/blank-lines-when-not-to-use/index.md b/content/docs/BestPractices/blank-lines-when-not-to-use/index.md index 3c9c5439..b9920ef4 100644 --- a/content/docs/BestPractices/blank-lines-when-not-to-use/index.md +++ b/content/docs/BestPractices/blank-lines-when-not-to-use/index.md @@ -51,3 +51,10 @@ if NameIsValid and Name2IsValid then ``` + +## Tips + +The [AZ AL Dev Tools/AL Code Outline](https://marketplace.visualstudio.com/items?itemName=andrzejzwierzchowski.al-code-outline) extension adds two new commands to Visual Studio Code to remove empty duplicate lines. + +- `Remove Empty Lines from the Active Editor` : removes empty duplicate lines from the current editor +- `Remove Empty Lines from the Active Project` : removes empty duplicate lines from the current project From 0b32513b19b68cdbfa07a44d93deac5320b0aa2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vercaemst?= Date: Fri, 6 May 2022 09:02:17 +0200 Subject: [PATCH 3/7] Added Tips section with link to VS Code extension #153 --- content/docs/BestPractices/blank-lines/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content/docs/BestPractices/blank-lines/index.md b/content/docs/BestPractices/blank-lines/index.md index 273882d7..c46bb0d6 100644 --- a/content/docs/BestPractices/blank-lines/index.md +++ b/content/docs/BestPractices/blank-lines/index.md @@ -157,3 +157,10 @@ local procedure OnAfterGetGLSetup(var GLSetup: Record "General Ledger Setup") begin end; ``` + +## Tips + +The [AZ AL Dev Tools/AL Code Outline](https://marketplace.visualstudio.com/items?itemName=andrzejzwierzchowski.al-code-outline) extension adds two new commands to Visual Studio Code to remove empty duplicate lines. + +- `Remove Empty Lines from the Active Editor` : removes empty duplicate lines from the current editor +- `Remove Empty Lines from the Active Project` : removes empty duplicate lines from the current project From 3cba72ce3f9cf3add8052da300da3ce2b5dde81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vercaemst?= Date: Fri, 6 May 2022 09:04:48 +0200 Subject: [PATCH 4/7] Added Tips section with link to VS Code extension --- content/docs/BestPractices/begin-end/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content/docs/BestPractices/begin-end/index.md b/content/docs/BestPractices/begin-end/index.md index f92bf395..964e5c40 100644 --- a/content/docs/BestPractices/begin-end/index.md +++ b/content/docs/BestPractices/begin-end/index.md @@ -52,3 +52,10 @@ if X then begin end else (not X) ``` + +## Tips + +The [AZ AL Dev Tools/AL Code Outline](https://marketplace.visualstudio.com/items?itemName=andrzejzwierzchowski.al-code-outline) extension adds two new commands to Visual Studio Code to remove begin..end around single statements. + +- `Remove Begin..End around Single Statements from the Active Editor` : removes begin..end around single statement from the current editor +- `Remove Begin..End around Single Statements from the Active Project` : removes begin..end around single statement from the current project From 56a903f358cb9d25a1122054e9c794fd8d1cd8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vercaemst?= Date: Fri, 6 May 2022 09:09:41 +0200 Subject: [PATCH 5/7] Added Tips section with link to VS Code extension #175 --- content/docs/BestPractices/named-invocations/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content/docs/BestPractices/named-invocations/index.md b/content/docs/BestPractices/named-invocations/index.md index 2aa77cc1..395848e4 100644 --- a/content/docs/BestPractices/named-invocations/index.md +++ b/content/docs/BestPractices/named-invocations/index.md @@ -21,3 +21,9 @@ When calling an object statically use the Object Name, not the Object Id. ```al Page.RunModal(Page::"Posted Sales Shipment Lines", SalesShptLine); ``` + +## Tips + +The [BusinessCentral.LinterCop](https://marketplace.visualstudio.com/items?itemName=StefanMaron.businesscentral-lintercop) extension adds a new rule to check your code for hardcoded object IDs. + +- [LC0012](https://github.com/StefanMaron/BusinessCentral.LinterCop/wiki/LC0012): Using hardcoded IDs in functions like Codeunit.Run() is not allowed. From ee06e3d83a7cddf37ca0ea2ca8b6c4f79535feed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vercaemst?= Date: Fri, 6 May 2022 09:12:09 +0200 Subject: [PATCH 6/7] Added Tips section with link to VS Code extension --- content/docs/BestPractices/variable-naming/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/docs/BestPractices/variable-naming/index.md b/content/docs/BestPractices/variable-naming/index.md index 3ead389b..80d9959a 100644 --- a/content/docs/BestPractices/variable-naming/index.md +++ b/content/docs/BestPractices/variable-naming/index.md @@ -51,3 +51,7 @@ If a variable is a compound of two or more words or abbreviations, each word or ```al AmountLCY: Decimal; ``` + +## Tips + +The [AL Variable Helper](https://marketplace.visualstudio.com/items?itemName=rasmus.al-var-helper) extension provides Intellisense support to assign correct variable names in AL. From a1c53ccbdf24fca87de4a4cc73b1a04b0534f822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vercaemst?= Date: Fri, 6 May 2022 09:13:50 +0200 Subject: [PATCH 7/7] Added Tips section with link to VSCode extension --- .../BestPractices/variables-declarations-order/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content/docs/BestPractices/variables-declarations-order/index.md b/content/docs/BestPractices/variables-declarations-order/index.md index 262b768f..8f7e2131 100644 --- a/content/docs/BestPractices/variables-declarations-order/index.md +++ b/content/docs/BestPractices/variables-declarations-order/index.md @@ -39,3 +39,10 @@ Variables declarations should be ordered by type. In general, object and complex Vendor: Record Vendor; StartingDateFilter: Text; ``` + +## Tips + +The [AZ AL Dev Tools/AL Code Outline](https://marketplace.visualstudio.com/items?itemName=andrzejzwierzchowski.al-code-outline) extension adds two new commands to Visual Studio Code to sorts variables. + +- `Sort Variables in the Active Editor` : sorts variables in the current editor +- `Sort Variables in the Active Project` : sorts variables in the current project