Restructure for Docsy theme
This commit is contained in:
parent
f4a1ebc077
commit
cceb0c945e
376 changed files with 963 additions and 186 deletions
35
content/docs/BestPractices/DeleteAll/index.md
Normal file
35
content/docs/BestPractices/DeleteAll/index.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
title: "DeleteAll"
|
||||
tags: ["Performance"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
<_Created by waldo, Described by waldo_\>
|
||||
|
||||
## Description
|
||||
|
||||
When you perform a "DeleteAll" when there is nothing to delete, it will still perform a lock. When you for example perform a DeleteAll on an empty table, it will result in a table lock.
|
||||
Therefore it's good practice to always check if the table is empty when performing a DeleteAll.
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
EmptyTableWLD.SetRange(Code, 'AJ');
|
||||
EmptyTableWLD.DeleteAll(true);
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
EmptyTableWLD.SetRange(Code, 'AJ');
|
||||
if not EmptyTableWLD.IsEmpty() then
|
||||
EmptyTableWLD.DeleteAll(true);
|
||||
```
|
||||
|
||||
## Discussions
|
||||
|
||||
You can discuss the guideline [here](https://github.com/microsoft/alguidelines/discussions/107)
|
||||
|
||||
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 free to create a new one with the same title as this article.
|
||||
197
content/docs/BestPractices/SubscriberCodeunits/index.md
Normal file
197
content/docs/BestPractices/SubscriberCodeunits/index.md
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
---
|
||||
title: "Subscriber Codeunits"
|
||||
tags: ["Performance"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_Created by waldo, Described by waldo_
|
||||
|
||||
## Description
|
||||
|
||||
In general, subscribers have to be put in codeunits. There are a few performance considerations that you should keep in the back of your minds, when designing such a codeunit.
|
||||
|
||||
- Keep the codeunit as small as possible
|
||||
- Work with a single instance codeunit
|
||||
- only subscribe when necessary
|
||||
- Avoid generic OnInsert/OnModify/OnDelete
|
||||
|
||||
Let's discuss all points
|
||||
|
||||
## Keep the codeunit as small as possible
|
||||
Every time a subscriber gets called, a new instance of the codeunit is being loaded in memory, which takes memory and processing power. The smaller the codeunit, the less memory, and the faster it is.
|
||||
|
||||
Therefore, it's suggested to split the subscribers by functionality and avoid putting business logic in the actual codeunit. Tip: put all business logic in an "[Method Codeunit](https://alguidelines.dev/bcpatterns/generic-method-pattern/)".
|
||||
|
||||
Examples:
|
||||
- if you app does things on Sales and Purchase, create a Sales-subs codeunit, and a Purchase-subs.
|
||||
- if you have multiple functionalities in your app (let's call'm modules), create a subs-codeunit per module, and only add the subscribers in there that are necessary for that module.
|
||||
|
||||
### Bad code
|
||||
```AL
|
||||
codeunit 2037325 "Setup Subs"
|
||||
{
|
||||
SingleInstance = true;
|
||||
|
||||
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Manual Setup", 'OnRegisterManualSetup', '', false, false)]
|
||||
local procedure OnRegisterManualSetup(sender: Codeunit "Manual Setup")
|
||||
var
|
||||
AppId: ModuleInfo;
|
||||
NameListLbl: Label 'Linked Texts Framework - List', Locked = true;
|
||||
DescriptionListLbl: Label 'Edit linked texts', Locked = true;
|
||||
KeyWordListLbl: Label 'LT,Distri,Technical,Functional,Reports', Locked = true;
|
||||
NameReportLbl: Label 'Linked Texts Framework - Reports', Locked = true;
|
||||
DescriptionReportLbl: Label 'View linked texts reports', Locked = true;
|
||||
KeyWordReportLbl: Label 'LT,Distri,Technical,Functional,Reports', Locked = true;
|
||||
begin
|
||||
navapp.GetCurrentModuleInfo(AppId);
|
||||
Sender.Insert(NameListLbl, DescriptionListLbl, KeyWordListLbl, page::"LTE Linked Text List", AppId.Id(), "Manual Setup Category"::General);
|
||||
Sender.Insert(NameReportLbl, DescriptionReportLbl, KeyWordReportLbl, page::"LTE Linked Texts Reports", AppId.Id(), "Manual Setup Category"::General);
|
||||
end;
|
||||
|
||||
[EventSubscriber(ObjectType::Codeunit, codeunit::"Manual Setup", 'OnRegisterManualSetup', '', false, false)]
|
||||
local procedure OnRegisterManualSetup(sender: Codeunit "Manual Setup")
|
||||
var
|
||||
AppId: ModuleInfo;
|
||||
NameLayoutLbl: Label 'Report Helper - Layout', Locked = true;
|
||||
DescriptionLayoutLbl: Label 'Set up or update report layout list', Locked = true;
|
||||
KeyWordLayoutLbl: Label 'RH,Distri,Technical,Functional,Reports,Layout', Locked = true;
|
||||
NameCaptionsLbl: Label 'Report Helper - Captions', Locked = true;
|
||||
DescriptionCaptionsLbl: Label 'Set up or update captions list', Locked = true;
|
||||
KeyWordCaptionsLbl: Label 'RH,Distri,Technical,Functional,Reports,Captions', Locked = true;
|
||||
NameFunctionsLbl: Label 'Report Helper - Functions', Locked = true;
|
||||
DescriptionFunctionsLbl: Label 'Set up or disable functions', Locked = true;
|
||||
KeyWordFunctionsLbl: Label 'RH,Distri,Technical,Functional,Reports,Functions', Locked = true;
|
||||
NameDFCLbl: Label 'Report Helper - Default Footer', Locked = true;
|
||||
DescriptionDFCLbl: Label 'Set up or update default footer', Locked = true;
|
||||
KeyWordDFCLbl: Label 'RH,Distri,Technical,Functional,Reports,Default,Footer', Locked = true;
|
||||
begin
|
||||
navapp.GetCurrentModuleInfo(AppId);
|
||||
Sender.Insert(NameLayoutLbl, DescriptionLayoutLbl, KeyWordLayoutLbl, page::"RHE Report Layout List", AppId.Id(), "Manual Setup Category"::General);
|
||||
Sender.Insert(NameCaptionsLbl, DescriptionCaptionsLbl, KeyWordCaptionsLbl, page::"RHE Captions", AppId.Id(), "Manual Setup Category"::General);
|
||||
Sender.Insert(NameFunctionsLbl, DescriptionFunctionsLbl, KeyWordFunctionsLbl, page::"RHE Functions", AppId.Id(), "Manual Setup Category"::General);
|
||||
Sender.Insert(NameDFCLbl, DescriptionDFCLbl, KeyWordDFCLbl, page::"RHE Default Footer Card", AppId.Id(), "Manual Setup Category"::General);
|
||||
end;
|
||||
}
|
||||
```
|
||||
### Good code
|
||||
|
||||
Split into 2 codeunits, and move the business logic out.
|
||||
|
||||
```AL
|
||||
codeunit 2037325 "LTE Setup Subs"
|
||||
{
|
||||
SingleInstance = true;
|
||||
|
||||
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Manual Setup", 'OnRegisterManualSetup', '', false, false)]
|
||||
local procedure OnRegisterManualSetup(sender: Codeunit "Manual Setup")
|
||||
var
|
||||
RegisterLTEManualSetup: codeunit "Register LTE Manual Setup";
|
||||
begin
|
||||
RegisterLTEManualSetup.RegisterLTEManualSetup();
|
||||
end;
|
||||
}
|
||||
|
||||
codeunit 2037324 "RHE Setup Subs"
|
||||
{
|
||||
SingleInstance = true;
|
||||
|
||||
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Manual Setup", 'OnRegisterManualSetup', '', false, false)]
|
||||
local procedure OnRegisterManualSetup(sender: Codeunit "Manual Setup")
|
||||
var
|
||||
RegisterRHEManualSetup: codeunit "Register RHE Manual Setup";
|
||||
begin
|
||||
RegisterRHEManualSetup.RegisterRHEManualSetup();
|
||||
end;
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Work with a single instance codeunit
|
||||
|
||||
To avoid the extra "loading of the content" while a subscriber is being executed, use Single Instance codeunit for subscribers. Do take into account, of course, that it would share the state across the entire session.
|
||||
|
||||
### Bad code
|
||||
```AL
|
||||
codeunit 2037324 "RHE Setup Subs"
|
||||
{
|
||||
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Manual Setup", 'OnRegisterManualSetup', '', false, false)]
|
||||
local procedure OnRegisterManualSetup(sender: Codeunit "Manual Setup")
|
||||
var
|
||||
RegisterRHEManualSetup: codeunit "Register RHE Manual Setup";
|
||||
begin
|
||||
RegisterRHEManualSetup.RegisterRHEManualSetup();
|
||||
end;
|
||||
}
|
||||
```
|
||||
### Good code
|
||||
```AL
|
||||
codeunit 2037324 "RHE Setup Subs"
|
||||
{
|
||||
SingleInstance = true;
|
||||
|
||||
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Manual Setup", 'OnRegisterManualSetup', '', false, false)]
|
||||
local procedure OnRegisterManualSetup(sender: Codeunit "Manual Setup")
|
||||
var
|
||||
RegisterRHEManualSetup: codeunit "Register RHE Manual Setup";
|
||||
begin
|
||||
RegisterRHEManualSetup.RegisterRHEManualSetup();
|
||||
end;
|
||||
}
|
||||
```
|
||||
|
||||
## only subscribe when necessary
|
||||
|
||||
If possible, only execute the subscriber when really necessary by using Manual Binding.
|
||||
|
||||
### Bad code
|
||||
```AL
|
||||
//subscriber - code should actually only run when Color=Red.
|
||||
[EventSubscriber(ObjectType::Table, Database::"Just Some Table WLD", 'OnAfterValidateEvent', 'Message 2', false, false)]
|
||||
local procedure JustDoSomthing(var Rec: Record "Just Some Table WLD"; var xRec: Record "Just Some Table WLD")
|
||||
begin
|
||||
if Rec.color <> 'RED' then
|
||||
exit; //only execute when necessary
|
||||
|
||||
...
|
||||
end;
|
||||
|
||||
//business logic
|
||||
if JustSomeTable.FindSet() then
|
||||
repeat
|
||||
JustSomeTable.Validate("Message 2", format(Random(1000)));
|
||||
until JustSomeTable.Next() < 1;
|
||||
```
|
||||
### Good code
|
||||
```AL
|
||||
if JustSomeTable.FindSet() then
|
||||
repeat
|
||||
if JustSomeTable.Color = 'RED' then
|
||||
BindSubscription(DemoSubs);
|
||||
|
||||
JustSomeTable.Validate("Message 2", format(Random(1000)));
|
||||
|
||||
if JustSomeTable.Color = 'RED' then
|
||||
UnbindSubscription(DemoSubs);
|
||||
until JustSomeTable.Next() < 1;
|
||||
```
|
||||
|
||||
## Avoid OnInsert/OnModify/OnDelete
|
||||
The reason for this is, that it breaks the batch-calls:
|
||||
- Any "OnInsert" subscriber breaks the bulk inserts, simply because it needs to perform an operation after every record that was inserted
|
||||
- Any "OnModify" subscriber slows down the "ModifyAll", simply because it needs to perform an operation after every record that was modified. I fact: 1 SQL call is turned into a loop of SQL calls.
|
||||
- Any "OnDelete" subscriber slows down the "DeleteAll", simply because it needs to perform an operation after every record that was deleted. I fact: 1 SQL call is turned into a loop of SQL calls.
|
||||
|
||||
Avoid subscribers to these events.
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/92)
|
||||
|
||||
You can discuss this guidelines [here](https://github.com/microsoft/alguidelines/discussions/92).
|
||||
|
||||
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 free to create a new one with the same title as this article.
|
||||
|
||||
## References
|
||||
|
||||
The [Generic Method Pattern](https://alguidelines.dev/bcpatterns/generic-method-pattern/)
|
||||
21
content/docs/BestPractices/_index.md
Normal file
21
content/docs/BestPractices/_index.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
title: "Best Practices"
|
||||
weight: 3
|
||||
description: >
|
||||
AL Code Best Practices
|
||||
---
|
||||
|
||||
# Business Central Best Practices
|
||||
|
||||
This section will be cover things that aren't as simple as Design Patterns, but will help make sure your development is:
|
||||
- high-performance
|
||||
- complies with good designs
|
||||
- has high maintainability
|
||||
|
||||
## Readability
|
||||
|
||||
Generally, all readability rules are Microsoft style choices only. You can use them to keep consistency with the existing code.
|
||||
|
||||
## Performance
|
||||
|
||||
Some guidelines are simply better for performance considerations rather than readability or anything else. In this section, let's look into some..
|
||||
34
content/docs/BestPractices/begin-as-an-afterword/index.md
Normal file
34
content/docs/BestPractices/begin-as-an-afterword/index.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
title: "begin as an afterword"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_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
|
||||
|
||||
```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 guideline, please feel free to create a new one with the same title as this article.
|
||||
60
content/docs/BestPractices/begin-end/index.md
Normal file
60
content/docs/BestPractices/begin-end/index.md
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
title: "Begin-End - Compound Only"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_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 free to create a new one with the same title as this article.
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
title: "Binary Operator to Start Line"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_Created by Microsoft, Described by waldo_
|
||||
|
||||
## Description
|
||||
|
||||
Do not start a line with a binary operator.
|
||||
|
||||
## Bad code
|
||||
|
||||
```AL
|
||||
"Quantity to Ship" :=
|
||||
Quantity
|
||||
- "Quantity Shipped"
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```AL
|
||||
"Quantity to Ship" :=
|
||||
Quantity -
|
||||
"Quantity Shipped"
|
||||
```
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=binary+operator+to+start+line+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 free to create a new one with the same title as this article.
|
||||
37
content/docs/BestPractices/case-actions/index.md
Normal file
37
content/docs/BestPractices/case-actions/index.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
title: "CASE Action on next line"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_Created by Microsoft, Described by waldo_
|
||||
|
||||
## Description
|
||||
|
||||
A CASE action should start on a line after the possibility.
|
||||
|
||||
## Bad code
|
||||
|
||||
```AL
|
||||
case Letter of
|
||||
'A': Letter2 := '10';
|
||||
'B': Letter2 := '11';
|
||||
end;
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```AL
|
||||
case Letter of
|
||||
'A':
|
||||
Letter2 := '10';
|
||||
'B':
|
||||
Letter2 := '11';
|
||||
end;
|
||||
```
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=case+action+on+next+line+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 free to create a new one with the same title as this article.
|
||||
29
content/docs/BestPractices/comments-spacing/index.md
Normal file
29
content/docs/BestPractices/comments-spacing/index.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
title: "Comment Spacing"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_Created by Microsoft, Described by waldo_
|
||||
|
||||
## Description
|
||||
Always start comments with // followed by one space character.
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
RowNo += 1000; //Move way below the budget
|
||||
```
|
||||
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
RowNo += 1000; // Move way below the budget
|
||||
```
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=comment+spacing+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 free to create a new one with the same title as this article.
|
||||
41
content/docs/BestPractices/end-else-pair/index.md
Normal file
41
content/docs/BestPractices/end-else-pair/index.md
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
title: "end else pair"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_Created by Microsoft, Described by waldo_
|
||||
|
||||
## Description
|
||||
|
||||
The `end else` pair should always appear on the same line.
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
if OppEntry.Find('-') then
|
||||
if SalesCycleStage.Find('-') then begin
|
||||
...
|
||||
end
|
||||
else
|
||||
begin
|
||||
...
|
||||
end;
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
if OppEntry.Find('-') then
|
||||
if SalesCycleStage.Find('-') then begin
|
||||
...
|
||||
end else begin
|
||||
...
|
||||
end;
|
||||
```
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=end+else/pair+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 free to create a new one with the same title as this article.
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: "Keyword Pairs - Indentation"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_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
|
||||
|
||||
```al
|
||||
if (x = y) and
|
||||
(a = b) then
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
if (x = y) and
|
||||
(a = b)
|
||||
then
|
||||
```
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=keyword+pair+indentation+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 free to create a new one with the same title as this article.
|
||||
37
content/docs/BestPractices/line-start-keywords/index.md
Normal file
37
content/docs/BestPractices/line-start-keywords/index.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
title: "Line Start Keywords"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
<_Created by Microsoft, Described by waldo_\>
|
||||
|
||||
## Description
|
||||
The `end`, `if`, `repeat`, `for`, `while`, `else` and `case` statement should always start a line.
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
if IsContactName then ValidateContactName()
|
||||
else if IsSalespersonCode then ValidateSalespersonCode()
|
||||
else if IsSalesCycleCode then ValidatSalesCycleCode();
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
if IsContactName then
|
||||
ValidateContactName()
|
||||
else
|
||||
if IsSalespersonCode then
|
||||
ValidateSalespersonCode()
|
||||
else
|
||||
if IsSalesCycleCode then
|
||||
ValidatSalesCycleCode();
|
||||
```
|
||||
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=line+start+keyword+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 free to create a new one with the same title as this article.
|
||||
29
content/docs/BestPractices/lonely-repeat/index.md
Normal file
29
content/docs/BestPractices/lonely-repeat/index.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
title: "Lonely Repeat"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_Created by Microsoft, Described by waldo_
|
||||
|
||||
## Description
|
||||
The `repeat` statement should always be alone on a line.
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
if ReservEntry.FindSet() then repeat
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
if ReservEntry.FindSet() then
|
||||
repeat
|
||||
```
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=lonely+repeat+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 free to create a new one with the same title as this article.
|
||||
28
content/docs/BestPractices/named-invocations/index.md
Normal file
28
content/docs/BestPractices/named-invocations/index.md
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
title: "Named Invocations"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_Created by Microsoft, Described by waldo_
|
||||
|
||||
## Description
|
||||
When calling an object statically use the Object Name, not the Object Id.
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
Page.RunModal(525, SalesShptLine);
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
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 free to create a new one with the same title as this article.
|
||||
44
content/docs/BestPractices/one-statement-per-line/index.md
Normal file
44
content/docs/BestPractices/one-statement-per-line/index.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
title: "One Statement per Line"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_Created by Microsoft, Described by waldo_
|
||||
|
||||
## Description
|
||||
A line of code should not have more than one statement.
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
if OppEntry.Find('-') then exit;
|
||||
```
|
||||
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
if OppEntry.Find('-') then
|
||||
exit;
|
||||
```
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
TotalCost += Cost; TotalAmt += Amt;
|
||||
```
|
||||
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
TotalCost += Cost;
|
||||
TotalAmt += Amt;
|
||||
```
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=one+statement+per+line+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 free to create a new one with the same title as this article.
|
||||
35
content/docs/BestPractices/separate-if-and-else/index.md
Normal file
35
content/docs/BestPractices/separate-if-and-else/index.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
title: "Seperate if and else"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_Created by Microsoft, Described by waldo_
|
||||
|
||||
## Description
|
||||
`if` and `else` statements should be on separate lines.
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
if Atom = '\>' then HasLogicalOperator := true else begin
|
||||
...
|
||||
end;
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
if Atom = '\>' then
|
||||
HasLogicalOperator := true
|
||||
else begin
|
||||
...
|
||||
end;
|
||||
```
|
||||
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=separate+if+and+else+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 free to create a new one with the same title as this article.
|
||||
46
content/docs/BestPractices/spacing-binary-operators/index.md
Normal file
46
content/docs/BestPractices/spacing-binary-operators/index.md
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
title: "Spacing Binary Operators"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_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
|
||||
|
||||
```al
|
||||
"Line Discount %" := "Line Discount Amount"/"Line Value"*100;
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
"Line Discount %" := "Line Discount Amount" / "Line Value" * 100;
|
||||
```
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
StartDate := CalcDate('<+'+Format(Days+i)+'D\>',StartDate);
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
StartDate := CalcDate('<+' + Format(Days + i) + 'D\>', StartDate);
|
||||
```
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
StartDate:=0D; // Initialize
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
StartDate := 0D; // Initialize
|
||||
```
|
||||
367
content/docs/BestPractices/suggested-abbreviations/index.md
Normal file
367
content/docs/BestPractices/suggested-abbreviations/index.md
Normal file
|
|
@ -0,0 +1,367 @@
|
|||
---
|
||||
title: "Suggested Abbreviations"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_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. | BA |
|
||||
| balance | Bal |
|
||||
| bill of materials | BOM |
|
||||
| blanket | Blnkt |
|
||||
| budget | Budg |
|
||||
| buffer | Buf |
|
||||
| business | Bus |
|
||||
| business interaction management | BIM |
|
||||
| buying | Buy |
|
||||
| calculate | Calc |
|
||||
| calculated | Calcd |
|
||||
| calculation | Calcu |
|
||||
| calendar | Cal |
|
||||
| capacity | Cap |
|
||||
| capacity requirements planning | CRP |
|
||||
| cash flow | CF |
|
||||
| cashflow | CF |
|
||||
| catalog | ctlg |
|
||||
| category | Cat |
|
||||
| Central Processing Unit | CPU |
|
||||
| center | Ctr |
|
||||
| change | Chg |
|
||||
| changes | Chgs |
|
||||
| character | Char |
|
||||
| characters | Chars |
|
||||
| charge | Chrg |
|
||||
| charges | Chrgs |
|
||||
| check | Chk |
|
||||
| classification | Class |
|
||||
| collection | coll |
|
||||
| column | col |
|
||||
| comment | Cmt |
|
||||
| company | Co |
|
||||
| component | Comp |
|
||||
| completion | Cmpltn |
|
||||
| components | Comps |
|
||||
| composition | Compn |
|
||||
| compression | Compr |
|
||||
| concurrent | Concrnt |
|
||||
| confidential | Conf |
|
||||
| confirmation | Cnfrmn |
|
||||
| conflict | Confl |
|
||||
| consolidate | Consol |
|
||||
| consolidation | Consolid |
|
||||
| consumption | Consump |
|
||||
| contact | Cont |
|
||||
| container | Cntr |
|
||||
| contract | Contr |
|
||||
| contracted | Contrd |
|
||||
| control | Ctrl |
|
||||
| controls | Ctrls |
|
||||
| conversion | Conv |
|
||||
| correction | Cor |
|
||||
| correspondence | Corres |
|
||||
| corresponding | Corresp |
|
||||
| cost | Cst |
|
||||
| sold | COGS |
|
||||
| credit | Cr |
|
||||
| cumulate | Cumul |
|
||||
| currency | Curr |
|
||||
| current | Crnt |
|
||||
| customer | Cust |
|
||||
| customer/vendor | CV |
|
||||
| daily | Dly |
|
||||
| dampener | Damp |
|
||||
| database management system | DBMS |
|
||||
| date | D |
|
||||
| definition | Def |
|
||||
| demonstration | Demo |
|
||||
| department | Dept |
|
||||
| department/project | DP |
|
||||
| depreciation | Depr |
|
||||
| description | Desc |
|
||||
| detail | Dtl |
|
||||
| detailed | Dtld |
|
||||
| details | Dtls |
|
||||
| deviation | Dev |
|
||||
| difference | Diff |
|
||||
| dimension | Dim |
|
||||
| direct | Dir |
|
||||
| discount | Disc |
|
||||
| discrete | Discr |
|
||||
| distribute | Distr |
|
||||
| distributed | Distrd |
|
||||
| distributor | Distbtr |
|
||||
| distribution | Distrn |
|
||||
| document | Doc |
|
||||
| duplicate | Dupl |
|
||||
| entered | Entrd |
|
||||
| engineering | Engin |
|
||||
| exchange | Exch |
|
||||
| excluding | Excl |
|
||||
| execute | Exec |
|
||||
| expected | Expd |
|
||||
| expedited | Exped |
|
||||
| expense | Exp |
|
||||
| expression | Expr |
|
||||
| expiration | Expir |
|
||||
| extended | Ext |
|
||||
| explode | Expl |
|
||||
| export | Expt |
|
||||
| final | Fnl |
|
||||
| finance | Fin |
|
||||
| fiscal | Fisc |
|
||||
| finished | Fnshd |
|
||||
| fixed asset | FA |
|
||||
| forward | Fwd |
|
||||
| freight | Frt |
|
||||
| general | Gen |
|
||||
| general ledger | GL |
|
||||
| group | Gr |
|
||||
| header | Hdr |
|
||||
| history | Hist |
|
||||
| holiday | Hol |
|
||||
| human resource | HR |
|
||||
| identification | ID |
|
||||
| import | Imp |
|
||||
| inbound | Inbnd |
|
||||
| including | Incl |
|
||||
| included | Incld |
|
||||
| incoming | Incmg |
|
||||
| independent software vendor | ISV |
|
||||
| industry | Indust |
|
||||
| information | Info |
|
||||
| initial | Init |
|
||||
| Intrastat | Intra |
|
||||
| interaction | Interact |
|
||||
| integration | Integr |
|
||||
| interest | Int |
|
||||
| Interim | Intm |
|
||||
| internal protocol | IP |
|
||||
| inventory | Invt |
|
||||
| inventoriable | Invtbl |
|
||||
| invoice | Inv |
|
||||
| invoiced | Invd |
|
||||
| item tracking | IT |
|
||||
| journal | Jnl |
|
||||
| language | Lang |
|
||||
| ledger | Ledg |
|
||||
| level | Lvl |
|
||||
| line | Ln |
|
||||
| list | Lt |
|
||||
| local currency | LCY |
|
||||
| location | Loc |
|
||||
| mailing | Mail |
|
||||
| maintenance | Maint |
|
||||
| management | Mgt |
|
||||
| manual | Man |
|
||||
| manufacturing | Mfg |
|
||||
| manufacturer | Mfr |
|
||||
| material | Mat |
|
||||
| marketing | Mktg |
|
||||
| maximum | Max |
|
||||
| measure | Meas |
|
||||
| message | Msg |
|
||||
| minimum | Min |
|
||||
| miscellaneous | Misc |
|
||||
| modify | Mod |
|
||||
| month | Mth |
|
||||
| negative | Neg |
|
||||
| non-inventoriable | NonInvtbl |
|
||||
| notification | Notif |
|
||||
| number | No |
|
||||
| numbers | Nos |
|
||||
| object | Obj |
|
||||
| operating | Oper |
|
||||
| opportunity | Opp |
|
||||
| order | Ord |
|
||||
| orders | Ords |
|
||||
| original | Orig |
|
||||
| organization | Org |
|
||||
| outbound | Outbnd |
|
||||
| Outgoing | Outg |
|
||||
| output | Out |
|
||||
| outstanding | Outstd |
|
||||
| overhead | Ovhd |
|
||||
| payment | Pmt |
|
||||
| percent | Pct |
|
||||
| personnel | Persnl |
|
||||
| physical | Phys |
|
||||
| picture | Pic |
|
||||
| planning | Plng |
|
||||
| posted | Pstd |
|
||||
| posting | Post |
|
||||
| positive | Pos |
|
||||
| precision | Prec |
|
||||
| prepayment | Prepmt |
|
||||
| product | Prod |
|
||||
| production | Prod |
|
||||
| production order | ProdOrd |
|
||||
| project | Proj |
|
||||
| property | Prop |
|
||||
| prospect | Prspct |
|
||||
| purchase | Purch |
|
||||
| purchases | Purch |
|
||||
| purchaser | Purchr |
|
||||
| purchase order | PurchOrd |
|
||||
| quality | Qlty |
|
||||
| quantity | Qty |
|
||||
| questionnaire | Questn |
|
||||
| quote | Qte |
|
||||
| radio frequency | RF |
|
||||
| range | Rng |
|
||||
| receipt | Rcpt |
|
||||
| received | Rcd |
|
||||
| record | Rec |
|
||||
| records | Recs |
|
||||
| reconcile | Recncl |
|
||||
| reconciliation | Recon |
|
||||
| recurring | Recur |
|
||||
| reference | Ref |
|
||||
| register | Reg |
|
||||
| registration | Regn |
|
||||
| registered | Regd |
|
||||
| relation | Rel |
|
||||
| relations | Rels |
|
||||
| relationship | Rlshp |
|
||||
| release | Rlse |
|
||||
| released | Rlsd |
|
||||
| remaining | Rem |
|
||||
| reminder | Rmdr |
|
||||
| replacement | Repl |
|
||||
| replenish | Rplnsh |
|
||||
| replenishment | Rplnsht |
|
||||
| report | Rpt |
|
||||
| represent | Rep |
|
||||
| represented | Repd |
|
||||
| request | Rqst |
|
||||
| required | Reqd |
|
||||
| requirement | Reqt |
|
||||
| requirements | Reqts |
|
||||
| requisition | Req |
|
||||
| reserve | Rsv |
|
||||
| reserved | Rsvd |
|
||||
| reservation | Reserv |
|
||||
| resolution | Resol |
|
||||
| resource | Res |
|
||||
| response | Rsp |
|
||||
| responsibility | Resp |
|
||||
| retain | Rtn |
|
||||
| retained | Rtnd |
|
||||
| return | Ret |
|
||||
| returns | Rets |
|
||||
| revaluation | Revaln |
|
||||
| reverse | Rev |
|
||||
| review | Rvw |
|
||||
| round | Rnd |
|
||||
| rounded | Rndd |
|
||||
| rounding | Rndg |
|
||||
| route | Rte |
|
||||
| routing | Rtng |
|
||||
| routine | Rout |
|
||||
| sales & receivables | Sales |
|
||||
| safety | Saf |
|
||||
| schedule | Sched |
|
||||
| second | Sec |
|
||||
| segment | Seg |
|
||||
| select | Sel |
|
||||
| selection | Selctn |
|
||||
| sequence | Seq |
|
||||
| serial | Ser |
|
||||
| serial number | SN |
|
||||
| service | Serv |
|
||||
| sheet | Sh |
|
||||
| shipment | Shpt |
|
||||
| source | Src |
|
||||
| special | Spcl |
|
||||
| specification | Spec |
|
||||
| specifications | Specs |
|
||||
| standard | Std |
|
||||
| frequency | SF |
|
||||
| statement | Stmt |
|
||||
| statistical | Stat |
|
||||
| statistics | Stats |
|
||||
| stock | Stk |
|
||||
| stockkeeping unit | SKU |
|
||||
| stream | Stm |
|
||||
| structured query language | SQL |
|
||||
| subcontract | Subcontr |
|
||||
| subcontracted | Subcontrd |
|
||||
| subcontracting | Subcontrg |
|
||||
| substitute | Sub |
|
||||
| substitution | Subst |
|
||||
| suggest | Sug |
|
||||
| suggested | Sugd |
|
||||
| suggestion | Sugn |
|
||||
| summary | Sum |
|
||||
| suspended | Suspd |
|
||||
| symptom | Sympt |
|
||||
| synchronize | Synch |
|
||||
| temporary | Temp |
|
||||
| total | Tot |
|
||||
| transaction | Transac |
|
||||
| transfer | Trans |
|
||||
| translation | Transln |
|
||||
| tracking | Trkg |
|
||||
| troubleshoot | Tblsht |
|
||||
| troubleshooting | Tblshtg |
|
||||
| unit of measure | UOM |
|
||||
| unit test | UT |
|
||||
| unrealized | Unreal |
|
||||
| unreserved | Unrsvd |
|
||||
| update | Upd |
|
||||
| valuation | Valn |
|
||||
| value | Val |
|
||||
| value added tax | VAT |
|
||||
| variance | Var |
|
||||
| vendor | Vend |
|
||||
| warehouse | Whse |
|
||||
| web shop | WS |
|
||||
| worksheet | Wksh |
|
||||
| g/l | GL |
|
||||
| % | Pct |
|
||||
| 3-tier | Three-Tier |
|
||||
| Outlook Synch | Osynch |
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=abbreviations+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 free to create a new one with the same title as this article.
|
||||
39
content/docs/BestPractices/unnecessary-else/index.md
Normal file
39
content/docs/BestPractices/unnecessary-else/index.md
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
title: "Unnecessary else"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_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
|
||||
|
||||
```al
|
||||
procedure SomeProcedure()
|
||||
begin
|
||||
if IsAdjmtBinCodeChanged() then
|
||||
Error(AdjmtBinCodeChangeNotAllowedErr, ...)
|
||||
else
|
||||
Error(BinCodeChangeNotAllowedErr, ...);
|
||||
end;
|
||||
```
|
||||
|
||||
## Good code
|
||||
```al
|
||||
procedure SomeProcedure()
|
||||
begin
|
||||
if IsAdjmtBinCodeChanged() then
|
||||
Error(AdjmtBinCodeChangeNotAllowedErr, ...)
|
||||
Error(BinCodeChangeNotAllowedErr, ...);
|
||||
end;
|
||||
```
|
||||
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=unnecessary+else+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 free to create a new one with the same title as this article.
|
||||
41
content/docs/BestPractices/unnecessary-truefalse/index.md
Normal file
41
content/docs/BestPractices/unnecessary-truefalse/index.md
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
title: "Unnecessary true/false"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_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
|
||||
|
||||
```al
|
||||
if IsPositive() = true then
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
if IsPositive() then
|
||||
```
|
||||
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
if Complete <> true then
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
if not Complete then
|
||||
```
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=unnecessary+true+false+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 free to create a new one with the same title as this article.
|
||||
48
content/docs/BestPractices/variable-naming/index.md
Normal file
48
content/docs/BestPractices/variable-naming/index.md
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
title: "Variable Naming"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_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.
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
WIPBuffer: Record "Job WIP Buffer"
|
||||
```
|
||||
## Good code
|
||||
```al
|
||||
JobWIPBuffer: Record "Job WIP Buffer"
|
||||
```
|
||||
## Bad code
|
||||
```al
|
||||
Postline: Codeunit "Gen. Jnl.-Post Line";
|
||||
```
|
||||
## Good code
|
||||
```al
|
||||
GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
|
||||
```
|
||||
## Bad code
|
||||
```al
|
||||
"Amount (LCY)": Decimal;
|
||||
```
|
||||
## Good code
|
||||
```al
|
||||
AmountLCY: Decimal;
|
||||
```
|
||||
|
||||
## [Discussions](https://github.com/microsoft/alguidelines/discussions/categories/bc-best-practices?discussions_q=one+variable+naming+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 free to create a new one with the same title as this article.
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
title: "Variables Declarations Order"
|
||||
tags: ["Readability"]
|
||||
categories: ["Best Practice"]
|
||||
---
|
||||
|
||||
_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](https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0021))
|
||||
|
||||
|
||||
## Bad code
|
||||
|
||||
```al
|
||||
StartingDateFilter: Text;
|
||||
Vendor: Record Vendor;
|
||||
```
|
||||
|
||||
## Good code
|
||||
|
||||
```al
|
||||
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 free to create a new one with the same title as this article.
|
||||
Loading…
Add table
Add a link
Reference in a new issue