Update AL coding guidelines to use PascalCase for variable and function names
- Corrected naming conventions in the AL code style documentation to specify PascalCase instead of camelCase for variables and functions. - Adjusted examples throughout the documentation to reflect the updated naming conventions. - Enhanced clarity in performance guidelines by renaming procedures for better understanding.
This commit is contained in:
parent
6b3f522a16
commit
2a805b20dc
6 changed files with 15 additions and 16 deletions
|
|
@ -11,7 +11,7 @@ alwaysApply: true
|
|||
These rules ensure consistent code structure and organization across AL projects, making code more maintainable and AI-assistant friendly.
|
||||
|
||||
## Style guidelines for AL code
|
||||
- Always use camelCase for variable and function names.
|
||||
- Always use PascalCase for variable and function names.
|
||||
- Use PascalCase for object names (e.g., tables, pages, reports).
|
||||
- Maintain a consistent indentation style (2 spaces preferred).
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ These rules ensure consistent code structure and organization across AL projects
|
|||
## Rule 1: Consistent Indentation and Formatting
|
||||
|
||||
### Intent
|
||||
Maintain consistent code formatting to improve readability and enable better AI understanding of code structure. Use 2-space indentation consistently throughout your project and maintain consistent formatting within functions and procedures.
|
||||
Maintain consistent code formatting to improve readability and enable better AI understanding of code structure. Use indentation with two spaces consistently throughout your project and maintain consistent formatting within functions and procedures.
|
||||
|
||||
### Examples
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ Implement proper event patterns to enable extensibility without modifying base a
|
|||
codeunit 50100 "Sales Document Events Handler"
|
||||
{
|
||||
[EventSubscriber(ObjectType::Table, Database::"Sales Header", OnBeforeInsert, '', false, false)]
|
||||
local procedure OnBeforeInsertSalesHeader(var Rec: Record "Sales Header"; RunTrigger: Boolean)
|
||||
local procedure OnBeforeInsertSalesHeader(var SalesHeader: Record "Sales Header"; RunTrigger: Boolean)
|
||||
begin
|
||||
// Custom validation logic
|
||||
ValidateCustomFields(Rec);
|
||||
ValidateCustomFields(SalesHeader);
|
||||
end;
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ The following rule sets provide comprehensive guidance for AL development:
|
|||
## Key Guidelines Summary
|
||||
|
||||
- **File Naming**: Use `<ObjectName>.<ObjectType>.al` pattern consistently
|
||||
- **Code Style**: Use 2-space indentation and camelCase for variables, PascalCase for objects
|
||||
- **Code Style**: Use two space indentation and PascalCase for variables, PascalCase for objects
|
||||
- **Folder Structure**: Organize by feature (`src/feature/subfeature/`) not by object type
|
||||
- **Performance**: Filter data early, use temporary tables, avoid unnecessary loops
|
||||
- **Events**: Prefer integration events over direct modifications for extensibility
|
||||
|
|
|
|||
|
|
@ -65,24 +65,24 @@ SalesPostingTests.Codeunit.al
|
|||
## Rule 3: Variable and Function Naming
|
||||
|
||||
### Intent
|
||||
Use consistent naming conventions for variables and functions to improve code readability. Use camelCase for variable and function names, descriptive names that clearly indicate purpose, and avoid abbreviations unless they are well-known business terms. Use consistent parameter naming in procedures.
|
||||
Use consistent naming conventions for variables and functions to improve code readability. Use PascalCase for variable and function names, descriptive names that clearly indicate purpose, and avoid abbreviations unless they are well-known business terms. Use consistent parameter naming in procedures.
|
||||
|
||||
### Examples
|
||||
|
||||
```al
|
||||
// Good examples - Variables
|
||||
var
|
||||
customerLedgerEntry: Record "Cust. Ledger Entry";
|
||||
totalAmount: Decimal;
|
||||
discountPercentage: Decimal;
|
||||
isValidTransaction: Boolean;
|
||||
CustomerLedgerEntry: Record "Cust. Ledger Entry";
|
||||
TotalAmount: Decimal;
|
||||
DiscountPercentage: Decimal;
|
||||
IsValidTransaction: Boolean;
|
||||
```
|
||||
|
||||
```al
|
||||
// Good examples - Functions
|
||||
procedure calculateCustomerBalance(customerNo: Code[20]): Decimal
|
||||
procedure validateSalesDocument(var salesHeader: Record "Sales Header")
|
||||
procedure updateInventoryQuantity(itemNo: Code[20]; quantity: Decimal)
|
||||
procedure CalculateCustomerBalance(CustomerNo: Code[20]): Decimal
|
||||
procedure ValidateSalesDocument(var SalesHeader: Record "Sales Header")
|
||||
procedure UpdateInventoryQuantity(ItemNo: Code[20]; Quantity: Decimal)
|
||||
```
|
||||
|
||||
## Rule 4: Parameter Naming in Event Subscribers
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ Optimize queries by filtering data as early as possible to reduce data transfer
|
|||
|
||||
```al
|
||||
// Good example - Early filtering
|
||||
procedure GetCustomersByCity(CityFilter: Text): Integer
|
||||
procedure GetNumberOfCustomersByCity(CityFilter: Text): Integer
|
||||
var
|
||||
Customer: Record Customer;
|
||||
begin
|
||||
|
|
@ -43,7 +43,7 @@ end;
|
|||
|
||||
```al
|
||||
// Bad example (avoid processing all records)
|
||||
procedure GetCustomersByCity(CityFilter: Text): Integer
|
||||
procedure GetNumberOfCustomersByCity(CityFilter: Text): Integer
|
||||
var
|
||||
Customer: Record Customer;
|
||||
Count: Integer;
|
||||
|
|
|
|||
|
|
@ -169,7 +169,6 @@ Organize test files to mirror the application structure while maintaining clear
|
|||
- Use same feature-based organization for tests
|
||||
- Place shared test utilities in Common folder
|
||||
- Maintain consistent naming patterns
|
||||
- When creating test files, mirror the feature organization of the App project but place all tests in the Test project structure
|
||||
|
||||
### Examples
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue