updated to darker color

This commit is contained in:
christianbraeunlich 2022-03-26 09:01:43 +01:00
parent bd7ea0e118
commit ccdaa1e08e
20 changed files with 57 additions and 57 deletions

View file

@ -11,14 +11,14 @@ _Created by waldo, Described by waldo_
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. 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. Therefore it's good practice to always check if the table is empty when performing a DeleteAll.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
EmptyTableWLD.SetRange(Code, 'AJ'); EmptyTableWLD.SetRange(Code, 'AJ');
EmptyTableWLD.DeleteAll(true); EmptyTableWLD.DeleteAll(true);
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
EmptyTableWLD.SetRange(Code, 'AJ'); EmptyTableWLD.SetRange(Code, 'AJ');

View file

@ -28,7 +28,7 @@ Examples:
- if you app does things on Sales and Purchase, create a Sales-subs codeunit, and a Purchase-subs. - 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. - 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.
### <span style="color:red">Bad code</span> ### <span style="color:FireBrick">Bad code</span>
```AL ```AL
codeunit 2037325 "Setup Subs" codeunit 2037325 "Setup Subs"
@ -77,7 +77,7 @@ codeunit 2037325 "Setup Subs"
} }
``` ```
### <span style="color:lime">Good code</span> ### <span style="color:ForestGreen">Good code</span>
Split into 2 codeunits, and move the business logic out. Split into 2 codeunits, and move the business logic out.
@ -115,7 +115,7 @@ codeunit 2037324 "RHE Setup Subs"
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. 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.
### <span style="color:red">Bad code</span> ### <span style="color:FireBrick">Bad code</span>
```AL ```AL
codeunit 2037324 "RHE Setup Subs" codeunit 2037324 "RHE Setup Subs"
@ -130,7 +130,7 @@ codeunit 2037324 "RHE Setup Subs"
} }
``` ```
### <span style="color:lime">Good code</span> ### <span style="color:ForestGreen">Good code</span>
```AL ```AL
codeunit 2037324 "RHE Setup Subs" codeunit 2037324 "RHE Setup Subs"
@ -151,7 +151,7 @@ codeunit 2037324 "RHE Setup Subs"
If possible, only execute the subscriber when really necessary by using Manual Binding. If possible, only execute the subscriber when really necessary by using Manual Binding.
### <span style="color:red">Bad code</span> ### <span style="color:FireBrick">Bad code</span>
```AL ```AL
//subscriber - code should actually only run when Color=Red. //subscriber - code should actually only run when Color=Red.
@ -171,7 +171,7 @@ If possible, only execute the subscriber when really necessary by using Manual B
until JustSomeTable.Next() < 1; until JustSomeTable.Next() < 1;
``` ```
### <span style="color:lime">Good code</span> ### <span style="color:ForestGreen">Good code</span>
```AL ```AL
if JustSomeTable.FindSet() then if JustSomeTable.FindSet() then

View file

@ -10,7 +10,7 @@ _Created by Microsoft, Described by waldo_
When `begin` follows `then`, `else`, `do`, it should be on the same line, preceded by one space character. When `begin` follows `then`, `else`, `do`, it should be on the same line, preceded by one space character.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
if ICPartnerRefType = ICPartnerRefType::"Common Item No." then if ICPartnerRefType = ICPartnerRefType::"Common Item No." then

View file

@ -8,7 +8,7 @@ _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.).
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```AL ```AL
if FindSet() then begin if FindSet() then begin
@ -18,7 +18,7 @@ if FindSet() then begin
end; end;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```AL ```AL
if FindSet() then if FindSet() then
@ -27,7 +27,7 @@ if FindSet() then
until next() = 0; until next() = 0;
``` ```
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```AL ```AL
if IsAssemblyOutputLine then begin if IsAssemblyOutputLine then begin
@ -35,7 +35,7 @@ if IsAssemblyOutputLine then begin
end; end;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```AL ```AL
if IsAssemblyOutputLine then if IsAssemblyOutputLine then

View file

@ -10,7 +10,7 @@ _Created by Microsoft, Described by waldo_
Do not start a line with a binary operator. Do not start a line with a binary operator.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```AL ```AL
"Quantity to Ship" := "Quantity to Ship" :=
@ -18,7 +18,7 @@ Quantity
- "Quantity Shipped" - "Quantity Shipped"
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```AL ```AL
"Quantity to Ship" := "Quantity to Ship" :=

View file

@ -10,7 +10,7 @@ _Created by Microsoft, Described by waldo_
A CASE action should start on a line after the possibility. A CASE action should start on a line after the possibility.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```AL ```AL
case Letter of case Letter of
@ -19,7 +19,7 @@ A CASE action should start on a line after the possibility.
end; end;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```AL ```AL
case Letter of case Letter of

View file

@ -10,13 +10,13 @@ _Created by Microsoft, Described by waldo_
Always start comments with // followed by one space character. Always start comments with // followed by one space character.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
RowNo += 1000; //Move way below the budget RowNo += 1000; //Move way below the budget
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
RowNo += 1000; // Move way below the budget RowNo += 1000; // Move way below the budget

View file

@ -10,7 +10,7 @@ _Created by Microsoft, Described by waldo_
The `end else` pair should always appear on the same line. The `end else` pair should always appear on the same line.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
if OppEntry.Find('-') then if OppEntry.Find('-') then
@ -23,7 +23,7 @@ The `end else` pair should always appear on the same line.
end; end;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
if OppEntry.Find('-') then if OppEntry.Find('-') then

View file

@ -10,14 +10,14 @@ _Created by Microsoft, Described by waldo_
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. 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.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
if (x = y) and if (x = y) and
(a = b) then (a = b) then
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
if (x = y) and if (x = y) and

View file

@ -9,7 +9,7 @@ _Created by Microsoft, Described by waldo_
The `end`, `if`, `repeat`, `for`, `while`, `else` and `case` statement should always start a line. The `end`, `if`, `repeat`, `for`, `while`, `else` and `case` statement should always start a line.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
if IsContactName then ValidateContactName() if IsContactName then ValidateContactName()
@ -17,7 +17,7 @@ The `end`, `if`, `repeat`, `for`, `while`, `else` and `case` statement should al
else if IsSalesCycleCode then ValidatSalesCycleCode(); else if IsSalesCycleCode then ValidatSalesCycleCode();
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
if IsContactName then if IsContactName then

View file

@ -10,13 +10,13 @@ _Created by Microsoft, Described by waldo_
The `repeat` statement should always be alone on a line. The `repeat` statement should always be alone on a line.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
if ReservEntry.FindSet() then repeat if ReservEntry.FindSet() then repeat
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
if ReservEntry.FindSet() then if ReservEntry.FindSet() then

View file

@ -10,13 +10,13 @@ _Created by Microsoft, Described by waldo_
When calling an object statically use the Object Name, not the Object Id. When calling an object statically use the Object Name, not the Object Id.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
Page.RunModal(525, SalesShptLine); Page.RunModal(525, SalesShptLine);
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
Page.RunModal(Page::"Posted Sales Shipment Lines", SalesShptLine); Page.RunModal(Page::"Posted Sales Shipment Lines", SalesShptLine);

View file

@ -10,26 +10,26 @@ _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.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
if OppEntry.Find('-') then exit; if OppEntry.Find('-') then exit;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
if OppEntry.Find('-') then if OppEntry.Find('-') then
exit; exit;
``` ```
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
TotalCost += Cost; TotalAmt += Amt; TotalCost += Cost; TotalAmt += Amt;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
TotalCost += Cost; TotalCost += Cost;

View file

@ -10,7 +10,7 @@ _Created by Microsoft, Described by waldo_
`if` and `else` statements should be on separate lines. `if` and `else` statements should be on separate lines.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
if Atom = '\>' then HasLogicalOperator := true else begin if Atom = '\>' then HasLogicalOperator := true else begin
@ -18,7 +18,7 @@ _Created by Microsoft, Described by waldo_
end; end;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
if Atom = '\>' then if Atom = '\>' then

View file

@ -10,37 +10,37 @@ _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.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
"Line Discount %" := "Line Discount Amount"/"Line Value"*100; "Line Discount %" := "Line Discount Amount"/"Line Value"*100;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
"Line Discount %" := "Line Discount Amount" / "Line Value" * 100; "Line Discount %" := "Line Discount Amount" / "Line Value" * 100;
``` ```
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
StartDate := CalcDate('<+'+Format(Days+i)+'D\>',StartDate); StartDate := CalcDate('<+'+Format(Days+i)+'D\>',StartDate);
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
StartDate := CalcDate('<+' + Format(Days + i) + 'D\>', StartDate); StartDate := CalcDate('<+' + Format(Days + i) + 'D\>', StartDate);
``` ```
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
StartDate:=0D; // Initialize StartDate:=0D; // Initialize
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
StartDate := 0D; // Initialize StartDate := 0D; // Initialize

View file

@ -10,7 +10,7 @@ _Created by Microsoft, Described by waldo_
`else` should not be used when the last action in the `then` part is an `exit`, `break`, `skip`, `quit`, `error`. `else` should not be used when the last action in the `then` part is an `exit`, `break`, `skip`, `quit`, `error`.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
procedure SomeProcedure() procedure SomeProcedure()
@ -22,7 +22,7 @@ _Created by Microsoft, Described by waldo_
end; end;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
procedure SomeProcedure() procedure SomeProcedure()

View file

@ -9,25 +9,25 @@ _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.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
if IsPositive() = true then if IsPositive() = true then
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
if IsPositive() then if IsPositive() then
``` ```
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
if Complete <> true then if Complete <> true then
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
if not Complete then if not Complete then

View file

@ -16,37 +16,37 @@ 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.
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
WIPBuffer: Record "Job WIP Buffer" WIPBuffer: Record "Job WIP Buffer"
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
JobWIPBuffer: Record "Job WIP Buffer" JobWIPBuffer: Record "Job WIP Buffer"
``` ```
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
Postline: Codeunit "Gen. Jnl.-Post Line"; Postline: Codeunit "Gen. Jnl.-Post Line";
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
``` ```
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
"Amount (LCY)": Decimal; "Amount (LCY)": Decimal;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
AmountLCY: Decimal; AmountLCY: Decimal;

View file

@ -26,14 +26,14 @@ Variables declarations should be ordered by type. In general, object and complex
(Ref: [Microsoft Docs](https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0021)) (Ref: [Microsoft Docs](https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0021))
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
StartingDateFilter: Text; StartingDateFilter: Text;
Vendor: Record Vendor; Vendor: Record Vendor;
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
Vendor: Record Vendor; Vendor: Record Vendor;

View file

@ -18,13 +18,13 @@ In depth description on what this Pattern is all about
- steps to implement - steps to implement
- considerations to take - considerations to take
## <span style="color:red">Bad code</span> ## <span style="color:FireBrick">Bad code</span>
```al ```al
PutCodeblocksHere() PutCodeblocksHere()
``` ```
## <span style="color:lime">Good code</span> ## <span style="color:ForestGreen">Good code</span>
```al ```al
PutCodeblocksHere() PutCodeblocksHere()