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

View file

@ -10,7 +10,7 @@ _Created by Microsoft, Described by waldo_
Do not start a line with a binary operator.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```AL
"Quantity to Ship" :=
@ -18,7 +18,7 @@ Quantity
- "Quantity Shipped"
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```AL
"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.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```AL
case Letter of
@ -19,7 +19,7 @@ A CASE action should start on a line after the possibility.
end;
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```AL
case Letter of

View file

@ -10,13 +10,13 @@ _Created by Microsoft, Described by waldo_
Always start comments with // followed by one space character.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
RowNo += 1000; //Move way below the budget
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
if OppEntry.Find('-') then
@ -23,7 +23,7 @@ The `end else` pair should always appear on the same line.
end;
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
if (x = y) and
(a = b) then
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
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();
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
if ReservEntry.FindSet() then repeat
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
Page.RunModal(525, SalesShptLine);
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
if OppEntry.Find('-') then exit;
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
if OppEntry.Find('-') then
exit;
```
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
TotalCost += Cost; TotalAmt += Amt;
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
TotalCost += Cost;

View file

@ -10,7 +10,7 @@ _Created by Microsoft, Described by waldo_
`if` and `else` statements should be on separate lines.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
if Atom = '\>' then HasLogicalOperator := true else begin
@ -18,7 +18,7 @@ _Created by Microsoft, Described by waldo_
end;
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
"Line Discount %" := "Line Discount Amount"/"Line Value"*100;
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
"Line Discount %" := "Line Discount Amount" / "Line Value" * 100;
```
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
StartDate := CalcDate('<+'+Format(Days+i)+'D\>',StartDate);
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
StartDate := CalcDate('<+' + Format(Days + i) + 'D\>', StartDate);
```
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
StartDate:=0D; // Initialize
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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`.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
procedure SomeProcedure()
@ -22,7 +22,7 @@ _Created by Microsoft, Described by waldo_
end;
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
procedure SomeProcedure()

View file

@ -9,25 +9,25 @@ _Created by Microsoft, Described by waldo_
## Description
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
if IsPositive() = true then
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
if IsPositive() then
```
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
if Complete <> true then
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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.
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
WIPBuffer: Record "Job WIP Buffer"
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
JobWIPBuffer: Record "Job WIP Buffer"
```
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
Postline: Codeunit "Gen. Jnl.-Post Line";
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line";
```
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
"Amount (LCY)": Decimal;
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
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))
## <span style="color:red">Bad code</span>
## <span style="color:FireBrick">Bad code</span>
```al
StartingDateFilter: Text;
Vendor: Record Vendor;
```
## <span style="color:lime">Good code</span>
## <span style="color:ForestGreen">Good code</span>
```al
Vendor: Record Vendor;