From a63b1597d8fe0f12569d121a52e527304120f3cb Mon Sep 17 00:00:00 2001 From: waldo1001 Date: Sat, 11 Dec 2021 08:14:24 +0100 Subject: [PATCH 1/4] begin as an 'After Word' --- content/BCBestPractices/Readability/_index.md | 11 +++++++ .../begin-as-an-afterword/index.md | 33 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 content/BCBestPractices/Readability/_index.md create mode 100644 content/BCBestPractices/Readability/begin-as-an-afterword/index.md diff --git a/content/BCBestPractices/Readability/_index.md b/content/BCBestPractices/Readability/_index.md new file mode 100644 index 00000000..f2c4c118 --- /dev/null +++ b/content/BCBestPractices/Readability/_index.md @@ -0,0 +1,11 @@ ++++ +title = "Readability" +weight = 980 ++++ +## AL Coding Guidelines + +## **Readability** + +Generally, all readability rules are Microsoft style choices only. You can use them to keep consistency with the existing code. + +Find the AL guidelines by expanding the menu in the left. diff --git a/content/BCBestPractices/Readability/begin-as-an-afterword/index.md b/content/BCBestPractices/Readability/begin-as-an-afterword/index.md new file mode 100644 index 00000000..3f7dc97d --- /dev/null +++ b/content/BCBestPractices/Readability/begin-as-an-afterword/index.md @@ -0,0 +1,33 @@ ++++ +title = "begin as an 'After Word'" +weight = 230 ++++ + +<_Created by Microsfot, Described by waldo_\> + +## Description + +When `begin` follows `then`, `else`, `do`, it should be on the same line, preceded by one space character. + +## Bad code + +```al + if ICPartnerRefType = ICPartnerRefType::"Common Item No." then + begin + ... + end; +``` + +## Good code + +```al + if ICPartnerRefType = ICPartnerRefType::"Common Item No." then begin + ... + end; +``` + +## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=begin+as+an+After+Word+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 pattern, please feel fee to create a new one with the same title as this article. \ No newline at end of file From d05bf6bbe4e91cd91227836b54897ee676ba3678 Mon Sep 17 00:00:00 2001 From: waldo1001 Date: Sat, 11 Dec 2021 08:15:52 +0100 Subject: [PATCH 2/4] Microsoft --- .../BCBestPractices/Readability/begin-as-an-afterword/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/BCBestPractices/Readability/begin-as-an-afterword/index.md b/content/BCBestPractices/Readability/begin-as-an-afterword/index.md index 3f7dc97d..e83c34e0 100644 --- a/content/BCBestPractices/Readability/begin-as-an-afterword/index.md +++ b/content/BCBestPractices/Readability/begin-as-an-afterword/index.md @@ -3,7 +3,7 @@ title = "begin as an 'After Word'" weight = 230 +++ -<_Created by Microsfot, Described by waldo_\> +<_Created by Microsoft, Described by waldo_\> ## Description From 36bee5f75f0f3b2a265ed8238a2f348782e5bc77 Mon Sep 17 00:00:00 2001 From: waldo1001 Date: Sat, 11 Dec 2021 08:16:43 +0100 Subject: [PATCH 3/4] Small changes to the template for guidelines --- .../Templates/Guidelines/index.md | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/content/Contributing/Templates/Guidelines/index.md b/content/Contributing/Templates/Guidelines/index.md index 030b859f..d4330a0b 100644 --- a/content/Contributing/Templates/Guidelines/index.md +++ b/content/Contributing/Templates/Guidelines/index.md @@ -6,10 +6,6 @@ This is a guideline, some parts are optional (if there's no content, remove the <_Created by (company), Described by (company)_\> -## Abstract - -Short, descriptive and easy to remember description of this pattern. - ## Description In depth description on what this Pattern is all about @@ -18,12 +14,23 @@ In depth description on what this Pattern is all about - steps to implement - considerations to take -## Good Example + +## Bad code + ```al PutCodeblocksHere() ``` -## Bad Example +## Good code + ```al PutCodeblocksHere() -``` \ No newline at end of file +``` + +## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=TITLEOFYOURGUIDELINEGOESHERE+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 pattern, please feel fee to create a new one with the same title as this article. \ No newline at end of file From 0c48ac5ad50fbbdecd10c0adf6ba751b0e845ed5 Mon Sep 17 00:00:00 2001 From: waldo1001 Date: Sat, 11 Dec 2021 08:29:14 +0100 Subject: [PATCH 4/4] Begin-End - Compound Only --- .../begin-as-an-afterword/index.md | 2 +- .../Readability/begin-end/index.md | 59 +++++++++++++++++++ .../Templates/Guidelines/index.md | 2 +- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 content/BCBestPractices/Readability/begin-end/index.md diff --git a/content/BCBestPractices/Readability/begin-as-an-afterword/index.md b/content/BCBestPractices/Readability/begin-as-an-afterword/index.md index e83c34e0..c9db894b 100644 --- a/content/BCBestPractices/Readability/begin-as-an-afterword/index.md +++ b/content/BCBestPractices/Readability/begin-as-an-afterword/index.md @@ -30,4 +30,4 @@ When `begin` follows `then`, `else`, `do`, it should be on the same line, preced 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 pattern, 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. \ No newline at end of file diff --git a/content/BCBestPractices/Readability/begin-end/index.md b/content/BCBestPractices/Readability/begin-end/index.md new file mode 100644 index 00000000..52394bff --- /dev/null +++ b/content/BCBestPractices/Readability/begin-end/index.md @@ -0,0 +1,59 @@ ++++ +title = "Begin-End - Compound Only" +weight = 240 ++++ + +<_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 + +```AL +if FindSet() then begin + repeat + ... + until next() = 0; +end; +``` + +## Good code + +```AL +IF FindSet() then + repeat + ... + until next() = 0; +``` + +## Bad code + +```AL +IF IsAssemblyOutputLine then begin + TestField("Order Line No.",0); +end; +``` + +## Good code + +```AL +IF IsAssemblyOutputLine then + TestField("Order Line No.",0); +``` + +## Exception + +```AL +// Except for this case +IF X then begin + IF Y then + //DO SOMETHING; +end else + (not X) +``` + +## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=begin+end+compound+only+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. diff --git a/content/Contributing/Templates/Guidelines/index.md b/content/Contributing/Templates/Guidelines/index.md index d4330a0b..b485f566 100644 --- a/content/Contributing/Templates/Guidelines/index.md +++ b/content/Contributing/Templates/Guidelines/index.md @@ -33,4 +33,4 @@ PutCodeblocksHere() 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 pattern, 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. \ No newline at end of file