Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How x++ handles classes, please help

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • Martin Dráb Profile Picture
    Martin Dráb 230,445 Most Valuable Professional on at
    RE: How x++ handles classes, please help

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How x++ handles classes, please help

    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 :)

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,445 Most Valuable Professional on at
    RE: How x++ handles classes, please help

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans