From 7cf65b3d3bd58a4179b3be4f9cfa095899c4ea52 Mon Sep 17 00:00:00 2001 From: christianbraeunlich Date: Thu, 17 Mar 2022 23:03:42 +0100 Subject: [PATCH 1/4] initial "avoid too many blank lines" best practice --- .../docs/BestPractices/blank-lines/index.md | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 content/docs/BestPractices/blank-lines/index.md diff --git a/content/docs/BestPractices/blank-lines/index.md b/content/docs/BestPractices/blank-lines/index.md new file mode 100644 index 00000000..e3c6185b --- /dev/null +++ b/content/docs/BestPractices/blank-lines/index.md @@ -0,0 +1,43 @@ +--- +title: "Avoid too many blank lines" +tags: ["AL"] +categories: ["Best Practice"] +--- + +## Description + +Avoid too many blank lines. + +## Bad code + +```al +var + IsVisible: Boolean; + IsEditable: Boolean; + + +local procedure Init() +begin + IsVisible := false; + IsEditable := false; + + + exit(true); +end; +``` + +## Good code + +```al +var + IsVisible: Boolean; + IsEditable: Boolean; + +local procedure Init() +begin + IsVisible := false; + IsEditable := false; + + exit(true); +end; +``` From 16aaca3614ad33b4302837011e765ea7610d38e9 Mon Sep 17 00:00:00 2001 From: christianbraeunlich Date: Sat, 19 Mar 2022 20:54:06 +0100 Subject: [PATCH 2/4] added some blank lines examples --- .../docs/BestPractices/blank-lines/index.md | 128 ++++++++++++++++-- 1 file changed, 119 insertions(+), 9 deletions(-) diff --git a/content/docs/BestPractices/blank-lines/index.md b/content/docs/BestPractices/blank-lines/index.md index e3c6185b..f02ddee7 100644 --- a/content/docs/BestPractices/blank-lines/index.md +++ b/content/docs/BestPractices/blank-lines/index.md @@ -1,6 +1,6 @@ --- title: "Avoid too many blank lines" -tags: ["AL"] +tags: ["AL","Readability"] categories: ["Best Practice"] --- @@ -12,17 +12,18 @@ Avoid too many blank lines. ```al var - IsVisible: Boolean; + UserSetup: Record "User Setup"; IsEditable: Boolean; + IsVisible: Boolean; -local procedure Init() +local procedure Initialize() begin - IsVisible := false; IsEditable := false; + IsVisible := false; - exit(true); + UserSetup.Get(); end; ``` @@ -30,14 +31,123 @@ end; ```al var - IsVisible: Boolean; + UserSetup: Record "User Setup"; IsEditable: Boolean; + IsVisible: Boolean; -local procedure Init() +local procedure Initialize() begin - IsVisible := false; IsEditable := false; + IsVisible := false; - exit(true); + UserSetup.Get(); +end; +``` + +## Bad code + +```al +page 50000 "Blank Lines" +{ + PageType = List; + ApplicationArea = All; + UsageCategory = Administration; + SourceTable = Customer; + + + layout + { + area(Content) + { + repeater(GroupName) + { + ShowCaption = false; + + + field(Name; Rec.Name) + { + ApplicationArea = All; + } + } + } + } +} +``` + +## Good code + +```al +page 50000 "Blank Lines" +{ + PageType = List; + ApplicationArea = All; + UsageCategory = Administration; + SourceTable = Customer; + + layout + { + area(Content) + { + repeater(GroupName) + { + ShowCaption = false; + + field(Name; Rec.Name) + { + ApplicationArea = All; + } + } + } + } +} +``` + +## Bad code + +```al +var + GLSetup: Record "General Ledger Setup"; + GLSetupRead: Boolean; + + +local procedure GetGLSetup() +begin + if not GLSetupRead then + GLSetup.Get(); + + + GLSetupRead := true; + + + OnAfterGetGLSetup(GLSetup); +end; + + +[IntegrationEvent(false, false)] +local procedure OnAfterGetGLSetup(var GLSetup: Record "General Ledger Setup") +begin +end; +``` + +## Good code + +```al +var + GLSetup: Record "General Ledger Setup"; + GLSetupRead: Boolean; + +local procedure GetGLSetup() +begin + if not GLSetupRead then + GLSetup.Get(); + + GLSetupRead := true; + + OnAfterGetGLSetup(GLSetup); +end; + +[IntegrationEvent(false, false)] +local procedure OnAfterGetGLSetup(var GLSetup: Record "General Ledger Setup") +begin end; ``` From 0c5f3b319d4fbea4833ef7bb80e3ca5f513eb8fc Mon Sep 17 00:00:00 2001 From: christianbraeunlich Date: Sat, 19 Mar 2022 21:35:07 +0100 Subject: [PATCH 3/4] added captions --- .../docs/BestPractices/blank-lines/index.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/content/docs/BestPractices/blank-lines/index.md b/content/docs/BestPractices/blank-lines/index.md index f02ddee7..0b3162b6 100644 --- a/content/docs/BestPractices/blank-lines/index.md +++ b/content/docs/BestPractices/blank-lines/index.md @@ -8,7 +8,9 @@ categories: ["Best Practice"] Avoid too many blank lines. -## Bad code +## #1 Example + +### Bad code ```al var @@ -27,7 +29,7 @@ begin end; ``` -## Good code +### Good code ```al var @@ -44,7 +46,9 @@ begin end; ``` -## Bad code +## #2 Example + +### Bad code ```al page 50000 "Blank Lines" @@ -74,7 +78,7 @@ page 50000 "Blank Lines" } ``` -## Good code +### Good code ```al page 50000 "Blank Lines" @@ -102,7 +106,9 @@ page 50000 "Blank Lines" } ``` -## Bad code +## #3 Example + +### Bad code ```al var @@ -129,7 +135,7 @@ begin end; ``` -## Good code +### Good code ```al var From ae3a259f5858a3a8f7d33da8fcb38670c78d0af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Br=C3=A4unlich?= Date: Tue, 5 Apr 2022 23:06:54 +0200 Subject: [PATCH 4/4] update example headers --- content/docs/BestPractices/blank-lines/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/docs/BestPractices/blank-lines/index.md b/content/docs/BestPractices/blank-lines/index.md index 0b3162b6..273882d7 100644 --- a/content/docs/BestPractices/blank-lines/index.md +++ b/content/docs/BestPractices/blank-lines/index.md @@ -8,7 +8,7 @@ categories: ["Best Practice"] Avoid too many blank lines. -## #1 Example +## Example 1 ### Bad code @@ -46,7 +46,7 @@ begin end; ``` -## #2 Example +## Example 2 ### Bad code @@ -106,7 +106,7 @@ page 50000 "Blank Lines" } ``` -## #3 Example +## Example 3 ### Bad code