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?
|
|
|
|
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)
|
|
|
|
|
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.
|
|
|
|
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.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close