web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How x++ handles classes, please help

(0) ShareShare
ReportReport
Posted on by

Hello guys, so i have a fundamental doubt. i been working with x++ for the past few days in project from work. but i dont get some of the functionality of x++.

practical example : 

i have to parse a file(flat text .txt)

the first line of the file is the HEADER : 232828278928cjeueocjJefreymark2872

the second one is a paymente registry : 839829209302vjieujhc28290vmneike

and there are a few other lines that have other type of registries.

so my job is to parse every line(from char 0 to char 11 is the account number for example) and to save that info into variables(and update some tables). that part is okey.

between header and the other lines there is some common fields, what i d normally d do in c#

is create  BASE class that has all the common fields and the method that parse those fields, then create a class HEADER,PAYMENTS and all the other lines that inherents from BASE so i d reuse the fields and the PARSE code instead of writing that every time.

the problem i found is that the classes in x++ dont seem to be made that way. every class is for a independent process and independent feature. is not used as a normal Object-oriented language d use it.

at least not the way i see it. could you tell how this is done properly in ax?hope you get what im trying to explain my english is not very good.

thanks

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,823 Most Valuable Professional on at

    What exactly do you miss in X++ regarding classes? It's all normal - inheritance, polymorphism, interfaces, you name it. I didn't get what else you need. Of course, you won't find many features that you're used to in C#, but none of them is necessary for OOP.

    It's also not true at all that every class is for an independent process - on the contrary, many processes use dozens of classes and some (general-enough) classes are used in thousands of processes.

    I agree that a lot of code in AX isn't very object-oriented, but it's fault of developers, not of X++. You don't have to, and shouldn't, follow bad patterns in code AX codebase.

  • Community Member Profile Picture
    on at

    Great to know . " It's also not true at all that every class is for an independent process - on the contrary, many processes use dozens of classes and some (general-enough) classes are used in thousands of processes.

    I agree that a lot of code in AX isn't very object-oriented, but it's fault of developers, not of X++. You don't have to, and shouldn't, follow bad patterns in code AX codebase." this part was really helpful, i ll do everything as it was c# not worrying about how its actually done in the AX codebase.  the ax codebase was what was troubling me. TY :)

  • Martin Dráb Profile Picture
    237,823 Most Valuable Professional on at

    Using good object-oriented design can't harm. :-)

    Nevertheless don't pretend that if you know the language, you know how to use it in all situations. If you know C#, you may know nothing about developing ASP.NET MVC, for example.

    AX has some specific and some ways how dealing with them. For example, you can easily call X++ methods on another machine (client <-> server), but it obviously takes much more time than calling normal methods. To avoid excessive client/server calls, AX has some patterns and frameworks, e.g. to collect user input on client, pack it, send it to server and do all processing there. If you're not aware of why it's done, it may make no sense to you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans