Notifications
Announcements
No record found.
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 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.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 551 Most Valuable Professional
André Arnaud de Cal... 450 Super User 2025 Season 2
BillurSamdancioglu 278 Most Valuable Professional