This document outlines rules for procedure accessibility in AL files to ensure proper testability, maintainability, and proper encapsulation practices in Business Central development.
- Internal Procedures: Internal procedures in the main app should remain
internal. They are accessible to the test app and do not need to be madepublic. - Do Not Use Local Procedures: Do not use
localprocedures, as they cannot be accessed or tested from the test app. All procedures that need to be accessed from the test app should be marked asinternal.
- Use
internalprocedures instead oflocalfor better testability - Keep procedures
internalunless they need to be exposed to other extensions - Make procedures
publiconly when they form part of the extension's public API - Document the intended accessibility level in procedure comments
- Design procedures with testing in mind from the start
- Ensure critical business logic is accessible to test codeunits
- Use dependency injection patterns where appropriate for external dependencies
- Consider creating test-specific interfaces for complex integrations
- Maintain proper encapsulation while ensuring testability
- Group related procedures logically within codeunits
- Use clear naming conventions that indicate the intended usage scope
- Document public interfaces thoroughly for consumers
By following these accessibility standards, you ensure that your code remains testable while maintaining proper encapsulation and access control throughout your AL development workflow.