The NEW Microsoft in Design Patterns


Hi everyone. It has been a while since I blogged and especially about patterns.

This is being written from Kastrup Airport Denmark and I just got back from Lyngby where I did a Master Class Summer School.

As always I had a lot of experienced people in the class and we ended up talking about legacy code and programming the “old” way and the “new” way.

Some programmers find it not so easy to see that our source code is improving. In this post I want to highlight some examples anyone can find in NAV2016 code that illustrates how Microsoft is moving forward and moving to more modern code in AL.

Natural Language Programming & Refactoring

I agree, it is not easy to find the places but Microsoft is moving into more readable code and doing refactoring.

About half a year ago I blogged about the refactoring Microsoft did in codeunit 80 and 90.

If you look at how they refactored you can clearly see that they are moving to more readable code, what I call “Natural Language Programming”.

MandatoryFields

 

Old Code

MandatoryFields2

Arguments Table

Another thing I blogged about last year is the introduction of the Arguments Table.

This is where Microsoft started to use a table as a class. The table has a function “Send”. Making this probably as close as we can get to OOP in AL.

ArgumentsEmail

Auto Increment

The Auto Increment property is a great way to solve performance issues caused by Transaction Isolation.

Microsoft changed the Reservation Entry table to be Auto Increment, instead of LOCKTABLE, FINDLAST, +1

Encapsulation

This was implemented in NAV long time ago in codeunit 99000854 Inventory Profile Offsetting

Encapsulation

So, you can see AL is a modern programming language that allow you to write decent code and Microsoft is taking the lead!

Enjoy summer

Advertisements
This entry was posted in Design Patterns, Dynamics NAV. Bookmark the permalink.

One Response to The NEW Microsoft in Design Patterns

  1. Kine says:

    I have one BIG problem with autoincrement – look into Change Log Entry for such a table… The PK is 0. Each time. You know why. BIG problem, mainly when you want to e.g. sync the data to another software etc.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s