“In the world of Business Central extensions, simplicity and upgradability are not just virtues - they’re necessities.”

alt text

PS> Get-BlogPostStructure -TableOfContents

Finding Your Zen: Guiding Principles for AL Development in Business Central Many developers are familiar with the “Zen of Python” – a set of guiding principles that shape how Python code is written, emphasizing simplicity and readability. It got me thinking: what would a “Zen of AL” look like for those of us developing extensions for Microsoft Dynamics 365 Business Central?

While the elegance of Python’s Zen is inspiring, AL development isn’t happening in a vacuum. We’re working within a complex ERP system. Business Central has its own specific rules, a rich data model, established business processes , and a crucial extensibility model. Simply applying general programming principles without considering the BC context – especially the need for seamless upgrades and rock-solid data integrity – can lead to trouble down the road.  

So, drawing inspiration from Python but grounding it firmly in the realities of the Business Central world, here’s a proposed “Zen of AL”:

The Zen of AL: A Quick Guide

Essentials

Guiding Principle Description
Extend, don’t modify Keep your custom code separate for seamless upgrades.
Events > Overrides Hook into processes, don’t replace them.
Readability > Upgrades Code that’s easy to understand today saves time tomorrow.
Business Logic > Codeunits Keep logic organized and easy to maintain.

Performance & Testing

Guiding Principle Description
Profile before optimizing Know what needs fixing before trying to fix it.
Test for the future Automate to prevent regressions and ensure upgradability.

Best Practices

Guiding Principle Description
Explicit > Implicit Be clear with data and logic to avoid confusion.
Error Handling > User Guidance Handle errors with care and guide the user.
Namespaces & Affixes > Collisions Prevent conflicts with standard objects.
Temporary Data > Handle with Care Temporary data is just that - temporary.
Understand the Standard > Extend Know the standard before customizing.

Upgradability & Data Integrity

Guiding Principle Description
Upgradability > Cleverness Prioritize upgradability over clever code.
Data Integrity > All Protect data integrity above all else.

Collaboration & Tools

Guiding Principle Description
Load Only What You Need Keep performance in mind when loading objects.
Embrace the Ecosystem > Leverage Tools Use the tools available to make your life easier.
Deprecate Cleanly > Clear Path Leave a clear path for future upgrades.
Consistency > Simplify Collaboration Consistency makes collaboration easier.

Philosophy

Guiding Principle Description
If it’s hard to explain, it’s a bad idea Keep it simple and easy to understand.
Now > Never Prioritize upgradability over immediate needs.

Diving into a Few Key Tenets

Extensibility & Upgrades 🚀

Let’s unpack a few of these that are particularly vital in the BC universe:

Extend, don’t modify: This is the absolute cornerstone. Forget the old C/AL days of changing base code. Modern AL development requires using extensions (TableExtension, PageExtension, etc.). Why? Upgradability. Extensions keep your custom code separate, allowing Microsoft’s frequent updates to roll out smoothly without breaking your solution. It’s a mindset shift: hook into processes, don’t change them.  

Events & Decoupling 📣

Events are better than overrides: Hand-in-hand with extending is using the event-driven model. Instead of trying to override standard logic (which you often can’t), you subscribe to events published by the base app or other extensions. This creates decoupling – your code reacts without the publisher needing to know about it. This is great for modularity and upgrades. Be mindful, though: subscriber execution order isn’t guaranteed , and the IsHandled pattern needs careful use to avoid unintended consequences.  

Prioritizing Upgradability 🚀

Upgradability trumps cleverness: This sums up a core trade-off. While a complex, “clever” solution might work now, if it’s hard to understand or relies on undocumented quirks, it’s a ticking time bomb for future upgrades. Prioritize solutions that are robust, maintainable, and align with the extension model, even if they seem slightly less elegant at first glance. Smooth upgrades are paramount in the SaaS world.  

alt text

Code Quality & Readability 📚

Readability counts, especially during upgrades: Clean, understandable code isn’t just nice; it’s essential. Code is read more than written , often by consultants, support teams, or future you during an upgrade. Unclear code makes maintenance, debugging, and adapting to BC updates much harder and costlier. Stick to naming conventions (PascalCase, Temp prefix) , format consistently (use the AL Formatter!) , structure logically , and use tools like CodeCop. Given BC’s lifecycle , readable code is a strategic must for future-proofing.  

alt text

Embracing the Ecosystem 🌈

Embrace the ecosystem; leverage the tools: Effective AL development isn’t just about the language. It’s about using the whole toolkit: VS Code with essential extensions (like the AL Language extension, Waldo’s AL Extension Pack, AL Object ID Ninja, GitLens) , Git for source control , Azure DevOps or GitHub for CI/CD (check out AL-Go for GitHub!) , and Docker with BCContainerHelper for consistent environments. Don’t forget the amazing community resources like blogs (Waldo, Stefano Demiliani, Yzhums, Vjeko Babic, Freddy Kristiansen, etc.) , sites like alguidelines.dev , forums , and events. Mastering these tools and engaging with the community makes you a much more productive and effective AL developer.  

The Path Forward

Adopting these principles isn’t about rigid rules but about fostering a mindset focused on building quality, long-lasting Business Central solutions. It leads to more reliable, maintainable, and upgradable extensions, which means happier clients and less stressful upgrades.  

Keep these ideas in mind as you code, discuss them with your team, and stay engaged with the community. Let’s keep refining the art of AL development together!