From a83d00e8a2126525dc2a5ba0c067dd3b930b4b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 07:49:06 +0100 Subject: [PATCH 01/12] Updated some casing mistakes --- content/BCBestPractices/Readability/begin-end/index.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/BCBestPractices/Readability/begin-end/index.md b/content/BCBestPractices/Readability/begin-end/index.md index 52394bff..41b2aeda 100644 --- a/content/BCBestPractices/Readability/begin-end/index.md +++ b/content/BCBestPractices/Readability/begin-end/index.md @@ -20,7 +20,7 @@ end; ## Good code ```AL -IF FindSet() then +if FindSet() then repeat ... until next() = 0; @@ -29,7 +29,7 @@ IF FindSet() then ## Bad code ```AL -IF IsAssemblyOutputLine then begin +if IsAssemblyOutputLine then begin TestField("Order Line No.",0); end; ``` @@ -37,7 +37,7 @@ end; ## Good code ```AL -IF IsAssemblyOutputLine then +if IsAssemblyOutputLine then TestField("Order Line No.",0); ``` @@ -45,8 +45,8 @@ IF IsAssemblyOutputLine then ```AL // Except for this case -IF X then begin - IF Y then +if X then begin + if Y then //DO SOMETHING; end else (not X) From 03c328bef95d20385b97541bba1434cdc042827c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 07:53:24 +0100 Subject: [PATCH 02/12] end; should also have a begin --- content/BCBestPractices/Readability/end-else-pair/index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/content/BCBestPractices/Readability/end-else-pair/index.md b/content/BCBestPractices/Readability/end-else-pair/index.md index 88511484..c654ebf0 100644 --- a/content/BCBestPractices/Readability/end-else-pair/index.md +++ b/content/BCBestPractices/Readability/end-else-pair/index.md @@ -17,6 +17,7 @@ The `end else` pair should always appear on the same line. ... end else + begin ... end; ``` @@ -27,7 +28,7 @@ The `end else` pair should always appear on the same line. if OppEntry.Find('-') then if SalesCycleStage.Find('-') then begin ... - end else + end else begin ... end; ``` @@ -36,4 +37,4 @@ The `end else` pair should always appear on the same line. You can find discussions on all "Best Practices" [here](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices). -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. \ No newline at end of file +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. From fc2f78581f70c883553cc4f3d60fc0a9ececd2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 07:54:59 +0100 Subject: [PATCH 03/12] a comma should be followed by a space --- .../BCBestPractices/Readability/named-invocations/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/BCBestPractices/Readability/named-invocations/index.md b/content/BCBestPractices/Readability/named-invocations/index.md index 285367cc..a4088e5f 100644 --- a/content/BCBestPractices/Readability/named-invocations/index.md +++ b/content/BCBestPractices/Readability/named-invocations/index.md @@ -11,17 +11,17 @@ When calling an object statically use the Object Name, not the Object Id. ## Bad code ```al - Page.RunModal(525,SalesShptLine) + Page.RunModal(525,SalesShptLine); ``` ## Good code ```al - Page.RunModal(Page::"Posted Sales Shipment Lines",SalesShptLine) + Page.RunModal(Page::"Posted Sales Shipment Lines", SalesShptLine); ``` ## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=named+invocations+category%3A%22BC+Best+Practices%22) You can find discussions on all "Best Practices" [here](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices). -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. \ No newline at end of file +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. From ff48e1a941079039cd0db4288a72ffe69fd889ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 07:55:39 +0100 Subject: [PATCH 04/12] sadly, exit with empty () does not compile --- .../Readability/one-statement-per-line/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/BCBestPractices/Readability/one-statement-per-line/index.md b/content/BCBestPractices/Readability/one-statement-per-line/index.md index 6ac25caa..e0bc59e0 100644 --- a/content/BCBestPractices/Readability/one-statement-per-line/index.md +++ b/content/BCBestPractices/Readability/one-statement-per-line/index.md @@ -19,7 +19,7 @@ A line of code should not have more than one statement. ```al if OppEntry.Find('-') then - exit(); + exit; ``` ## Bad code @@ -40,4 +40,4 @@ A line of code should not have more than one statement. You can find discussions on all "Best Practices" [here](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices). -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. \ No newline at end of file +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. From 8bbfe01ede00f092dddb3aa58d84c35905d717af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 07:56:09 +0100 Subject: [PATCH 05/12] sadly, exit with () does not compile --- .../BCBestPractices/Readability/one-statement-per-line/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/BCBestPractices/Readability/one-statement-per-line/index.md b/content/BCBestPractices/Readability/one-statement-per-line/index.md index e0bc59e0..c5085b87 100644 --- a/content/BCBestPractices/Readability/one-statement-per-line/index.md +++ b/content/BCBestPractices/Readability/one-statement-per-line/index.md @@ -11,7 +11,7 @@ A line of code should not have more than one statement. ## Bad code ```al - if OppEntry.Find('-') then exit(); + if OppEntry.Find('-') then exit; ``` From 34c84872b82e59c84b8466ee0ad6f285365a803c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 07:57:45 +0100 Subject: [PATCH 06/12] casing of TRUE is not the point of this bad code example --- .../BCBestPractices/Readability/separate-if-and-else/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/BCBestPractices/Readability/separate-if-and-else/index.md b/content/BCBestPractices/Readability/separate-if-and-else/index.md index 77938943..b74acec1 100644 --- a/content/BCBestPractices/Readability/separate-if-and-else/index.md +++ b/content/BCBestPractices/Readability/separate-if-and-else/index.md @@ -11,7 +11,7 @@ weight = 1050 ## Bad code ```al - if Atom = '\>' then HasLogicalOperator := TRUE else begin + if Atom = '\>' then HasLogicalOperator := true else begin ... end; ``` @@ -31,4 +31,4 @@ weight = 1050 You can find discussions on all "Best Practices" [here](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices). -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. \ No newline at end of file +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. From 0fde42cc6e14db403f043b06084f439b4ffb44a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 07:59:20 +0100 Subject: [PATCH 07/12] calling a procedure without parameters should have empty () --- .../BCBestPractices/Readability/unnecessary-else/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/BCBestPractices/Readability/unnecessary-else/index.md b/content/BCBestPractices/Readability/unnecessary-else/index.md index c3b0f301..ffad9056 100644 --- a/content/BCBestPractices/Readability/unnecessary-else/index.md +++ b/content/BCBestPractices/Readability/unnecessary-else/index.md @@ -13,7 +13,7 @@ weight = 1270 ```al procedure SomeProcedure() begin - if IsAdjmtBinCodeChanged then + if IsAdjmtBinCodeChanged() then Error(AdjmtBinCodeChangeNotAllowedErr,...) else Error(BinCodeChangeNotAllowedErr,...); @@ -24,7 +24,7 @@ weight = 1270 ```al procedure SomeProcedure() begin - if IsAdjmtBinCodeChanged then + if IsAdjmtBinCodeChanged() then Error(AdjmtBinCodeChangeNotAllowedErr,...) Error(BinCodeChangeNotAllowedErr,...); end; @@ -35,4 +35,4 @@ weight = 1270 You can find discussions on all "Best Practices" [here](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices). -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. \ No newline at end of file +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. From 4f0394811d74491b409070f9972ad72cdc051271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 08:00:19 +0100 Subject: [PATCH 08/12] removed spaces --- .../Readability/variable-naming/index.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/BCBestPractices/Readability/variable-naming/index.md b/content/BCBestPractices/Readability/variable-naming/index.md index 858d973b..6ac4d757 100644 --- a/content/BCBestPractices/Readability/variable-naming/index.md +++ b/content/BCBestPractices/Readability/variable-naming/index.md @@ -17,19 +17,19 @@ If a variable is a compound of two or more words or abbreviations, each word or ## Bad code ```al - WIPBuffer : Record "Job WIP Buffer" + WIPBuffer: Record "Job WIP Buffer" ``` ## Good code ```al - JobWIPBuffer : Record "Job WIP Buffer" + JobWIPBuffer: Record "Job WIP Buffer" ``` ## Bad code ```al - Postline : Codeunit "Gen. Jnl.-Post Line"; + Postline: Codeunit "Gen. Jnl.-Post Line"; ``` ## Good code ```al - GenJnlPostLine : Codeunit "Gen. Jnl.-Post Line"; + GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; ``` ## Bad code ```al @@ -44,4 +44,4 @@ If a variable is a compound of two or more words or abbreviations, each word or You can find discussions on all "Best Practices" [here](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices). -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. \ No newline at end of file +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. From bc38408c78367f47f8dcb3fbf939e99471116653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 08:02:08 +0100 Subject: [PATCH 09/12] Removed spaces --- .../Readability/variables-declarations-order/index.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/BCBestPractices/Readability/variables-declarations-order/index.md b/content/BCBestPractices/Readability/variables-declarations-order/index.md index d5b47167..7ec97cc5 100644 --- a/content/BCBestPractices/Readability/variables-declarations-order/index.md +++ b/content/BCBestPractices/Readability/variables-declarations-order/index.md @@ -28,19 +28,19 @@ Variables declarations should be ordered by type. In general, object and complex ## Bad code ```al - StartingDateFilter : Text; - Vendor : Record Vendor; + StartingDateFilter: Text; + Vendor: Record Vendor; ``` ## Good code ```al - Vendor : Record Vendor; - StartingDateFilter : Text; + Vendor: Record Vendor; + StartingDateFilter: Text; ``` ## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=one+variables+declarations+order+category%3A%22BC+Best+Practices%22) You can find discussions on all "Best Practices" [here](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices). -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. \ No newline at end of file +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. From 0de6d15d69e80827ee08928749dac0d73b3f280c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 08:03:19 +0100 Subject: [PATCH 10/12] spaces after commas --- content/BCBestPractices/Readability/begin-end/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/BCBestPractices/Readability/begin-end/index.md b/content/BCBestPractices/Readability/begin-end/index.md index 41b2aeda..a2bcf372 100644 --- a/content/BCBestPractices/Readability/begin-end/index.md +++ b/content/BCBestPractices/Readability/begin-end/index.md @@ -30,7 +30,7 @@ if FindSet() then ```AL if IsAssemblyOutputLine then begin - TestField("Order Line No.",0); + TestField("Order Line No.", 0); end; ``` @@ -38,7 +38,7 @@ end; ```AL if IsAssemblyOutputLine then - TestField("Order Line No.",0); + TestField("Order Line No.", 0); ``` ## Exception From 9b7917e4848e4ebcdcf29c6468d231f2f4c5c9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 08:05:45 +0100 Subject: [PATCH 11/12] Space after comma --- content/BCBestPractices/Readability/named-invocations/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/BCBestPractices/Readability/named-invocations/index.md b/content/BCBestPractices/Readability/named-invocations/index.md index a4088e5f..e6c2ae03 100644 --- a/content/BCBestPractices/Readability/named-invocations/index.md +++ b/content/BCBestPractices/Readability/named-invocations/index.md @@ -11,7 +11,7 @@ When calling an object statically use the Object Name, not the Object Id. ## Bad code ```al - Page.RunModal(525,SalesShptLine); + Page.RunModal(525, SalesShptLine); ``` ## Good code From b20f5ffb41f167eed199430ea9a310bb2cc336af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Maro=C5=84?= Date: Wed, 15 Dec 2021 08:07:28 +0100 Subject: [PATCH 12/12] Spaces after comma --- .../BCBestPractices/Readability/unnecessary-else/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/BCBestPractices/Readability/unnecessary-else/index.md b/content/BCBestPractices/Readability/unnecessary-else/index.md index ffad9056..ee900d0a 100644 --- a/content/BCBestPractices/Readability/unnecessary-else/index.md +++ b/content/BCBestPractices/Readability/unnecessary-else/index.md @@ -14,9 +14,9 @@ weight = 1270 procedure SomeProcedure() begin if IsAdjmtBinCodeChanged() then - Error(AdjmtBinCodeChangeNotAllowedErr,...) + Error(AdjmtBinCodeChangeNotAllowedErr, ...) else - Error(BinCodeChangeNotAllowedErr,...); + Error(BinCodeChangeNotAllowedErr, ...); end; ``` @@ -25,8 +25,8 @@ weight = 1270 procedure SomeProcedure() begin if IsAdjmtBinCodeChanged() then - Error(AdjmtBinCodeChangeNotAllowedErr,...) - Error(BinCodeChangeNotAllowedErr,...); + Error(AdjmtBinCodeChangeNotAllowedErr, ...) + Error(BinCodeChangeNotAllowedErr, ...); end; ```