Not too long ago, I followed one of Steve Endow’s amazing livestreams where he was talking about BC Coding Guidelines together with Henrik and Jeremy. And what I noticed was that it appeared to be that “coding guidelines” – whatever they are for you – are hard to find – at least if you’re searching for guidelines in the new AL Language. I was like, wait a minute, I know I have been talking about that for a LOT during sessions and on blogs .. and others must have as well .. but when searching .. it appeared to be not *that* much at all, and usually not in the right context. So, my assumptions were wrong, and the necessity of that session, in my opinion, is high!
Before I continue with the actual topic, there is one thing I need to highlight from that session. Well, in fact, there are more, but just watch the entire session here:
What I wanted to highlight is the site Jeremy created: CAL Rules Review (sparebrained.com). It’s a site that will share C/AL guidelines – of which many are still quite interesting today in AL – and even lets you vote about some guidelines as well. Check it out!
So – there are barely any guidelines online, and the ones there are, are old, or hard to find. Well, recently, I did a session at DynamicsCon about “How do I manage my Dev team” (at the time of this post, it’s not on YouTube just yet), and part of managing the team, IS applying development guidelines.
So why not go deeper into the topic, and share whatever I find important within my company on my blog.
And I thought it was a good idea to kick off with a treasure of information that got buried over time. A community project I’m proud to have been part of. Something I still think is valuable, even in the world of AL. A project that was baptised with the name …
The NAV Design Patterns Wiki
You can find the wiki here: https://community.dynamics.com/nav/w/designpatterns
And you might wonder: why bring that old stuff up? It was a community project that has been abandoned, that isn’t being updated or maintained anymore. And you are right.
But …
It’s still an awesome list of patterns, written by quite some people that put a great deal of time into it. They put time into, first of all, document the patterns of default NAV, and second of all, they came up with a great deal of new patterns that can help in many situations. It’s documented, and I believe that many of them are still very valid even today. Not all – and you’ll need to decide which ones don’t! But I’m telling you: many still are very valid today!
I was actually surprised that it got so little attention during Steve’s talk. Sure, it’s pretty old, but so are the C/AL guidelines from the so called “old guidebook” ;-). May be the only reason why I’m so passionate about this project is because I was part of it, and I loved spending time on it ;-).
Jeremy mentioned the current state of the site was bad. It was very difficult to navigate. And he is totally right. It’s an absolute nightmare to navigate, since on the main pages, there isn’t really good information (only an attempt for a tagged list, basically). The really interesting information you can find in the menu on the right, ONLY when you click the arrows, not the links. You really need to click the tiny triangles to expand the list on the right. And even when you select one item of that list, it would collapse back .. . Again, it’s a nightmare! Let’s just think of it like “internet erosion” over time .. 😉.
To save you the trouble and help you navigate to those pages, I decided to copy/paste the list right here, where every single link will navigate back to the original wiki, including comments, and the original author.
Just have a look at this treasure of information:
Intro
Patterns
.NET Exception Handling in C/AL
– TryFunction – .NET Exception Handling in C/AL
Activity Log
Argument Table
Blocked Entity
– Data-driven Blocked Entity
Cached Web Service Calls
Conditional Cascading Update
Copy Document
Create Data from Templates
Create URLs to NAV Clients
Creating Custom Charts
Cross Session Events
Currently Active Record
Data Migration Façade
Discovery Event
Document
Easy Update of Setup or Supplementary Information
Error Message Processing
Extending the Role Center Headlines
Feature Localization for Data Structures
Hooks
Implementation of surrogate keys using AutoIncrement pattern
Instructions in the UI
Integration of Addresses
Journal Error Processing
Journal Template-Batch-Line
Master Data
Multi-File Download
Multi-Page List
Multilanguage Application Data
No. Series
Notifications
– In-context notifications
Observer
Posting Routine – Select behavior
Product Name
Queries
– SELECT DISTINCT with Queries
– Use Queries to Detect Duplicate Records
– Use Queries to replace Nested Loops
Read Once Initialization and Validation
Released Entity
Report Selection
Security
1. Sensitive Data Encapsulation
2. Data Encryption
3. Single Point of Access
4. Masked Text
5. SSL in NAV
Setup Specificity Fallback
Silent File Upload and Download
Singleton
– Singleton Codeunit
– Singleton Table
— Cue Table
— Setup Table
Standard Journal
Temporary Dataset Report
Totals and Discounts on Subpages (Sales and Purchases)
Transfer Custom Fields
Variant Façade
Anti-Patterns
C/AL Coding Guidelines
Design
- By Reference Parameters
- Class Coupling
- Cyclomatic complexity
- Encapsulate local functionality
- FINDSET, FINDFIRST, FINDLAST
- Initialized variables
- Maintainability index
- Parameter placeholders
- Static object invocation
- Unreachable code
- Unused initialized variables
- Unused variables
- Variable capacity mismatch
- WITH scope name collision
Internally used Dot Net Types
Internationalization
Localizability
- CaptionML for system tables
- FIELDCAPTION and TABLECAPTION
- Global Text Constants
- Use Text Constants
- Using OptionCaptionML
Readability
- BEGIN as an afterword
- BEGIN..END
- Binary operator line start
- Blank lines
- CASE actions
- Colon usage in CASE
- Comments: curly brackets
- Comments: spacing
- END ELSE pair
- Indentation
- Keyword pairs indentation
- Line-start keywords
- Lonely REPEAT
- Named invocations
- Nested WITHs
- One statement per line
- Separate IF and ELSE
- Spacing: binary operators
- Spacing: brackets and ::
- Spacing: unary operators
- Temporary variable naming
- TextConst suffixes
- Unary operator line end
- Unnecessary Compound Parenthesis
- Unnecessary ELSE
- Unnecessary Function Parenthesis
- Unnecessary separators
- Unnecessary TRUE/FALSE
- Variable already scoped
- Variable naming
- Variables declarations order
Suggested Abbreviations
UX
As I mentioned – it’s not made for AL – it was even created when there wasn’t even any notion of AL. Even the concept of “events” was even VERY new at that time, as far as I remember.
One example is the Hooks pattern, which was one of my personal favourite patterns that got completely useless now that we have events and extension objects..
You will kind of have to decide what will be valid for you and what not.
But in my opinion, it’s a great way to start sharing about AL guidelines. This was just a first post – I’m planning more posts in the near (further 😉) future about guidelines that we apply in our company to keep our software under control. No promise (my wife says I’m bad in keeping promises), but an attempt .. ;-).
9 comments
6 pings
Skip to comment form
I have been on the site (NAV Design patterns) a few times and honestly the info there is invaluable (treasure). I hope you get the chance to do more posts on AL Coding Guidelines because I really enjoy your blog posts.
Author
Thanks so much – really appreciate it!
Still a valuable resource, thanks for bringing it on the front line. Pattern are in the heart of the product since the early beginning : a reliable way to offer consistency in UX and in under the hood of course.
It was a pleasure for me to document… the document pattern 🙂
Hey there Waldo, thanks so much for your collection/work. We like it a lot as an info source.
All Links lead to Page not Found Errors.
I hope you can do something about it.
Author
New location: https://alguidelines.dev/docs/navpatterns/
Thank you!
Hello Waldo, unable to access those links.
Author
The wiki is no more, but we were able to save the data: https://alguidelines.dev/docs/navpatterns/
[…] AL Development guideline 1: the “NAV Design Patterns Wiki” […]
[…] Source : Waldo’s Blog Read more… […]
[…] you can see on one of my previous posts – I initially was planning to share a bunch of guidelines with you, starting with a first: a […]
[…] you can see on one of my previous posts – I initially was planning to share a bunch of guidelines with you, starting with a first: a […]
[…] you’ll be able to see on certainly one of my earlier posts – I initially was planning to share a bunch of pointers with you, beginning with a primary: a […]
[…] you can see on one of my previous posts – I initially was planning to share a bunch of guidelines with you, starting with a first: a […]