X++, the catch

“When building a cannon, make sure the cannon ball comes out in the right direction.” This is a piece of advice I heard many years ago. I think, we in generally have been following the advice in the Dynamics AX platform group. The APIs and designs have been easy to understand, and without side-effects. This…

23

C# 7.0 – an X++ developer’s dream coming true?

  Today I attended an excellent TechTalk on C# 7.0 by Mads Torgersen at a full house in Microsoft Development Center Copenhagen.   As the talk unfolded I was struck by Déjà vu– this is not the first time I’ve heard Mads present a new feature in C#, that I’ve been using for a long…

8

X++ in AX7: Attributes without specifying ”Attribute”

The naming convention in X++ (and C# by the way) is to postfix attribute classes’ name with “Attribute”. When using the attribute to decorate a class, it is a bit verbose to type in “Attribute” as it is apparent from the context, so now in X++ – just like in C# – you can skip…

0

X++ in AX7: String truncation

Consider this X++ code:  CustGroupId id = “012345678901234567890123456789”; //30 chars long;   CustGroup custgroup;   custGroup.id = id;  custGroup.insert;    select custGroup     where custGroup.id == id;   The CustGroupID EDT is defined with a length of 20 characters. In AX 2012 the assignment in the very first line would truncate the string from 30 to 20 characters. The record would be inserted and selected again. In AX7 the CustGroupID EDT is being compiled as…

2

X++ in AX7: Garbage Collection

In AX 2012 the runtime can either be the .NET CLR executing IL code, or the AX interpreter executing pcode. From a Garbage Collection point of view these two behaves extremely different. The difference is like night and day.   In AX7 only the .NET CLR Garbage Collector is in play.        …

0

X++ in AX7: Method signatures

This post is about one of the more subtle changes in AX7. AX7 uses the .NET runtime, aka CLR. This has some implications for method signatures. In the CLR a method’s signature includes casing, parameters and return type. In AX2012 a method’s signature was simply the method’s name – case insensitive. Why is this important?…

2

X++ in AX7: Inline variable declarations

What would you pay to be able to do this in X++? for (int i = 1; i <= n; i++)   {}     Or this: if (i > 0)    {    int positiveInt = i;  }   Or this: if (applyInterestRate){    real rate = this.getInterestRate();      result = result * rate;  }  if (applyExchangeRate) {      ExchangeRate rate = this.getExchangeRate();      result = result * rate.ExchangeRate;  }   Finally, we can: Declare variables close(r) to where they are used, Variables are scoped by the block in which they are declared, and Variable names can be reused in another scope. The price: Join…

0

X++ in AX7: Const keyword

In AX7 X++ now supports the const keyword. Semantically it is identical to const in C#. In short; it allows you to define members on a class and variables in a method that can only be initialized during the declaration. The compiler will replace references to these constants with the literal value. In other words,…

5

X++ in AX7: Extension methods

Have you ever experienced a Microsoft provided class or table missing that vital method that would just make your life easier? If so, you might have been tempted to add it yourself using overlayering. And you surely have paid the upgrade price! You are about to be pleased. In AX7 X++ supports extension methods, similarly to…

14

X++ in AX7: Readonly keyword

In AX7 X++ now supports the readonly keyword. Semantically it is identical to readonly in C#. In short; it allows you to define members on a class that can only be initialized in the declaration and in the constructor. class MyClass {      readonly str identifier = “XYZ”;      readonly str identifier2;       public void new(str _identifier)     {          identifier2 = _identifier;      }       public void foo()     {         // The field ‘identifier2’ is read only. A value cannot be assigned to it.         //identifier2 = “ABC”;       }  }   The big question is “when to use it?” In my opinion the…

0