AL icon indicating copy to clipboard operation
AL copied to clipboard

In Defense of Codeunit 1

Open jcooper01 opened this issue 8 years ago • 5 comments

I have noticed that in the daily builds, Codeunit 1 has been removed from the application. I understand that several versions ago, most of the Codeunit 1 business logic was moved into separate management codeunits in the 40 range, and Codeunit 1 merely contained pointers to the new objects. Therefore, it would seem like the obvious next step would be to remove Codeunit 1 entirely, given that it is merely a shell of its former self. However, I would like to make an argument against its unceremonious removal.

As an ISV that has been publishing multiple popular products in the NAV space for more than a decade, we have customers on many NAV versions, ranging from 3.6 to 2018. When NAV 2016 was released with support for eventing and extensions, we completely refactored all of our products to be entirely event-driven. This allowed us to fairly easily move our application between NAV versions, as we no longer had any code on native objects. Now, when we release new versions of our products, we back-port and forward-port those releases to NAV versions 2016-2018 using deltas. We are able to have a single codebase for our products that will function on multiple NAV versions, as well as on Business Central (as we have built Txt2AL into our build scripts).

As changes have been made to the native application, we have adapted our products to accommodate for these changes (the removal of Product Groups, the addition of Application Areas, etc.). Given the recent removal of Codeunit 1 in the daily build, we have even removed references in our products to the Codeunit 1 functions for formatting and replaced them with calls directly to the new 4X codeunits.

However, one thing that we can't adapt to is the loss of the events in Codeunit 1. We subscribe to OnAfterCaptionClassTranslate so that we can create custom captions on the fly to make our product easier to set up. This event does not exist in Codeunit 42 (CaptionManagement) in NAV 2016, 2017, or 2018, but it seems to have moved there from Codeunit 1 in recent daily builds of Business Central. That means that we will need to split our codebase - one branch that subscribes to the event in Codeunit 1, and another that subscribes to it in Codeunit 42. It also means that there needs to be a coordinated rollout of apps that subscribe to Codeunit 1 events because when the Business Central version that contains this change is pushed to production, it will break existing apps.

I would like to propose that you leave Codeunit 1 in the product and make each function simply call the new functions in the 4X codeunits. In addition, the 4X codeunits should fire the Codeunit 1 events for backwards compatibility. I know that the NAV team has been working hard on refactoring legacy code, but the removal of such an important event publisher seems hasty and the benefit seems negligible. As a long-time NAV (and now Business Central) ISV, it would be beneficial to us and to your customers to leave Codeunit 1 in the product. It will allow us to continue to move our latest releases easily between versions, and it will prevent the looming breaking event that will come when the new version goes to production.

Thank you for your consideration,

Jon Cooper ChargeLogic

jcooper01 avatar Jul 12 '18 13:07 jcooper01

Hi Jon,

thanks for the feedback, we will take it under advisement.

Have you considered adding the events in the new locations in your NAV 2016/2017/2018 implementations so they match the new version? If that works for you, let us know as we could add them in a cumulative update for those versions.

br/Gert

grobyns avatar Jul 12 '18 18:07 grobyns

Hi all, I found error when open Dynamic NAV image It reference codeunit 1. Please help me with this proplem.

NAV Version: 13.0.23231.0-W1

Thanks

chiecnhanco avatar Jul 13 '18 02:07 chiecnhanco

@chiecnhanco: Please create a separate issue for this so we get a bug we can track in our system.

cheers, Gert

grobyns avatar Jul 13 '18 08:07 grobyns

Hi, I'm closing this issue as there has not been a comment for a while. br/Gert

grobyns avatar Jul 20 '18 07:07 grobyns

Sorry for the delay in response. Adding the events in the new locations in older versions isn't an option. We have extension versions for NAV 2016, 2017, and 2018, so, as you know, we can't make code changes to native objects. In fact, even if Microsoft made those code changes in a CU, that also wouldn't help us, as we release our software for the RTM build of each version.

jcooper01 avatar Jul 20 '18 14:07 jcooper01