added caption for each example
This commit is contained in:
parent
5652ea8c5d
commit
6162a121be
5 changed files with 48 additions and 24 deletions
|
|
@ -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.).
|
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
|
```AL
|
||||||
if FindSet() then begin
|
if FindSet() then begin
|
||||||
|
|
@ -18,7 +20,7 @@ if FindSet() then begin
|
||||||
end;
|
end;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```AL
|
```AL
|
||||||
if FindSet() then
|
if FindSet() then
|
||||||
|
|
@ -27,7 +29,9 @@ if FindSet() then
|
||||||
until next() = 0;
|
until next() = 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Bad code
|
## Example 2
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
```AL
|
```AL
|
||||||
if IsAssemblyOutputLine then begin
|
if IsAssemblyOutputLine then begin
|
||||||
|
|
@ -35,7 +39,7 @@ if IsAssemblyOutputLine then begin
|
||||||
end;
|
end;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```AL
|
```AL
|
||||||
if IsAssemblyOutputLine then
|
if IsAssemblyOutputLine then
|
||||||
|
|
|
||||||
|
|
@ -10,26 +10,30 @@ _Created by Microsoft, Described by waldo_
|
||||||
|
|
||||||
A line of code should not have more than one statement.
|
A line of code should not have more than one statement.
|
||||||
|
|
||||||
## Bad code
|
## Example 1
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
if OppEntry.Find('-') then exit;
|
if OppEntry.Find('-') then exit;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
if OppEntry.Find('-') then
|
if OppEntry.Find('-') then
|
||||||
exit;
|
exit;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Bad code
|
## Example 2
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
TotalCost += Cost; TotalAmt += Amt;
|
TotalCost += Cost; TotalAmt += Amt;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
TotalCost += Cost;
|
TotalCost += Cost;
|
||||||
|
|
|
||||||
|
|
@ -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.
|
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
|
```al
|
||||||
"Line Discount %" := "Line Discount Amount"/"Line Value"*100;
|
"Line Discount %" := "Line Discount Amount"/"Line Value"*100;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
"Line Discount %" := "Line Discount Amount" / "Line Value" * 100;
|
"Line Discount %" := "Line Discount Amount" / "Line Value" * 100;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Bad code
|
## Example 2
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
StartDate := CalcDate('<+'+Format(Days+i)+'D\>',StartDate);
|
StartDate := CalcDate('<+'+Format(Days+i)+'D\>',StartDate);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
StartDate := CalcDate('<+' + Format(Days + i) + 'D\>', StartDate);
|
StartDate := CalcDate('<+' + Format(Days + i) + 'D\>', StartDate);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Bad code
|
## Example 3
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
StartDate:=0D; // Initialize
|
StartDate:=0D; // Initialize
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
StartDate := 0D; // Initialize
|
StartDate := 0D; // Initialize
|
||||||
|
|
|
||||||
|
|
@ -9,25 +9,29 @@ _Created by Microsoft, Described by waldo_
|
||||||
## Description
|
## Description
|
||||||
Do not use `true` or `false` keywords unnecessarily if the expression is already an logical expression.
|
Do not use `true` or `false` keywords unnecessarily if the expression is already an logical expression.
|
||||||
|
|
||||||
## Bad code
|
## Example 1
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
if IsPositive() = true then
|
if IsPositive() = true then
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
if IsPositive() then
|
if IsPositive() then
|
||||||
```
|
```
|
||||||
|
|
||||||
## Bad code
|
## Example 2
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
if Complete <> true then
|
if Complete <> true then
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
if not Complete then
|
if not Complete then
|
||||||
|
|
|
||||||
|
|
@ -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.
|
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
|
```al
|
||||||
WIPBuffer: Record "Job WIP Buffer"
|
WIPBuffer: Record "Job WIP Buffer"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
JobWIPBuffer: Record "Job WIP Buffer"
|
JobWIPBuffer: Record "Job WIP Buffer"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Bad code
|
## Example 2
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
Postline: Codeunit "Gen. Jnl.-Post Line";
|
Postline: Codeunit "Gen. Jnl.-Post Line";
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
|
GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
|
||||||
```
|
```
|
||||||
|
|
||||||
## Bad code
|
## Example 3
|
||||||
|
|
||||||
|
### Bad code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
"Amount (LCY)": Decimal;
|
"Amount (LCY)": Decimal;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Good code
|
### Good code
|
||||||
|
|
||||||
```al
|
```al
|
||||||
AmountLCY: Decimal;
|
AmountLCY: Decimal;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue