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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Is it recommended to use IOC(autofac) and interfaces with x++?

(0) ShareShare
ReportReport
Posted on by 465

I want to try and apply the D in SOLID design patterns.

I noticed that x++ standard code barely use interfaces.

So if i made a c# code for autofac and made interfaces in x++ code and used them together, is that recommended? or i should not do it?

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

    I don't think anybody will tell you that it's recommended, because it's not normally used, especially when your question is about one particular IoC container (autofac). I would start by exploring whether it's possible or not. Maybe you could have a singleton class holding the container, initialize it in something like Application.startupPost() and then use it in your code. Be also aware of that support for generics in X++ isn't good.

    The native solution in F&O is using plugins (utilizing things like ExportAttribute, as it's done in MEF), but they're a bit cumbersome.

    Also note that designing for Dependency Injection doesn't require IoC containers. The focus is on getting dependencies from outside, but it might simply mean that your class accept a dependency (declared as an interface) in a method parameter.

  • Shadowchamber Profile Picture
    30 on at

    I use IOC often but not on application level.

    I configure container with dependencies in main method usually for various jobs.

    It works nice and really useful for unit testing (I've uploaded my simple ioc container at github called NDinject with example, not sure if anyone need but let it be there github.com/.../NDinject).

    It also can be useful for forms but it is more complicated to implement however useful for testing (kind of MVP pattern) and actually it is not required cause we have atl with kinda ui testing.

    As for me it is good to use IOC so I recommend it but to be honest not many projects are using unit testing at all (at least projects where I worked or working now)

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans