Microsoft has created the new ALAppExtensions with a bunch of functions we constantly use. We often create, in our apps, codeunits with helper functions.
When we use these functions, we have to declare somewhere a codeunit variable everywhere and I am proposing here to be able to declare "static" codeunits.
It would be just a compiler trick but the idea would be that:
- Like dotnet.al, we create a file "staticcodeunits.al" where MyHelperCodeunit is given an alias like MyHelper.
- Anywhere in my app, instead of writing :
MyHelper: codeunit MyHelperCodeunit;
It could be written:
In our apps, we would be able to use functions like Math.Min, Math.Max, StreamHelper.ToBase64() exactly like Dialog.Message or Text.StrSubstNo.
The static functions on enums give an idea of the syntax that could apply: Codeunit::"MyHelpercodeunit".DoSomething()
I would like to extend this idea to static procedures and a static property for the Codeunit itself (to be applied to all contained procedures automatically). This would need some more work to differentiate between static/nonstatic functions, but the "only" requirement is to not call/use instance procedures or instance variables in my opinion.
Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we might consider it in the future.
Business Central Team