logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Joe Payne2  
#1 Posted : Wednesday, June 30, 2021 3:41:42 PM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
I'm curious why Able code always passes the windsor castle IOC references in the constructor for a controller? Why not just declare the entire repo reference at the top of each class instead of declaring empty instances and then assigning them via the controller class constructor?

Code:

        private IOrderReturnRepository _orderReturnsRepo = AbleContext.Container.Resolve<IOrderReturnRepository>();
        private IOrderRepairRepository _orderRepairsRepo = AbleContext.Container.Resolve<IOrderRepairRepository>();
        private IReturnReasonRepository _returnReasonsRepo = AbleContext.Container.Resolve<IReturnReasonRepository>();
        private IOrderIssueRepository _orderIssuesRepo = AbleContext.Container.Resolve<IOrderIssueRepository>();
        private IWarehouseRepository _warehouseRepo = AbleContext.Container.Resolve<IWarehouseRepository>();


I mean, it's not like they can be truly dynamic i.e. they can't be changed on the fly without a full recompile of the app. So if I implemented a different container, I'd have to recompile anyways and my private declarations would pick up the new reference anyways.

Am I missing how windsor works?

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

Joe Payne2  
#2 Posted : Tuesday, July 13, 2021 10:15:37 AM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
Anyone?
mazhar  
#3 Posted : Tuesday, July 13, 2021 11:45:14 AM(UTC)
mazhar

Rank: Administration

Groups: Admin, Administrators, HelpDesk, System, Authorized User, Developers, Registered
Joined: 10/5/2018(UTC)
Posts: 175

Thanks: 8 times
Was thanked: 17 time(s) in 15 post(s)
There are different approaches when it comes to providing the dependencies. The constructor injection makes more sense for non-optional dependencies and you know what an object needs when you try to make use of it.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.