From 2a805b20dcb5845565230453af43c0a12e69c6a3 Mon Sep 17 00:00:00 2001 From: Dmitry Katson Date: Wed, 30 Jul 2025 22:08:25 +0800 Subject: [PATCH] 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. --- content/docs/vibe-coding/al-code-style.md | 4 ++-- content/docs/vibe-coding/al-events.md | 4 ++-- content/docs/vibe-coding/al-guidelines-rules.md | 2 +- .../docs/vibe-coding/al-naming-conventions.md | 16 ++++++++-------- content/docs/vibe-coding/al-performance.md | 4 ++-- content/docs/vibe-coding/al-testing.md | 1 - 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/content/docs/vibe-coding/al-code-style.md b/content/docs/vibe-coding/al-code-style.md index 6e1aea24..a8f429ef 100644 --- a/content/docs/vibe-coding/al-code-style.md +++ b/content/docs/vibe-coding/al-code-style.md @@ -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 diff --git a/content/docs/vibe-coding/al-events.md b/content/docs/vibe-coding/al-events.md index 20afabfc..8eab527c 100644 --- a/content/docs/vibe-coding/al-events.md +++ b/content/docs/vibe-coding/al-events.md @@ -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; } ``` diff --git a/content/docs/vibe-coding/al-guidelines-rules.md b/content/docs/vibe-coding/al-guidelines-rules.md index e01462bd..f0caf625 100644 --- a/content/docs/vibe-coding/al-guidelines-rules.md +++ b/content/docs/vibe-coding/al-guidelines-rules.md @@ -36,7 +36,7 @@ The following rule sets provide comprehensive guidance for AL development: ## Key Guidelines Summary - **File Naming**: Use `..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 diff --git a/content/docs/vibe-coding/al-naming-conventions.md b/content/docs/vibe-coding/al-naming-conventions.md index 0de377f6..f5bed480 100644 --- a/content/docs/vibe-coding/al-naming-conventions.md +++ b/content/docs/vibe-coding/al-naming-conventions.md @@ -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 diff --git a/content/docs/vibe-coding/al-performance.md b/content/docs/vibe-coding/al-performance.md index e9d9c156..9e4aa7aa 100644 --- a/content/docs/vibe-coding/al-performance.md +++ b/content/docs/vibe-coding/al-performance.md @@ -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; diff --git a/content/docs/vibe-coding/al-testing.md b/content/docs/vibe-coding/al-testing.md index 68bc9370..2c09aff0 100644 --- a/content/docs/vibe-coding/al-testing.md +++ b/content/docs/vibe-coding/al-testing.md @@ -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