Timeline for How to avoid a crazy amount of interfaces in UI with dependency injection?
Current License: CC BY-SA 3.0
26 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 23, 2016 at 13:19 | audit | Close votes | |||
| May 23, 2016 at 13:19 | |||||
| May 6, 2016 at 15:51 | comment | added | R. Schmitz | Because the children need to be given to listeners so they can call back. | |
| May 4, 2016 at 15:43 | comment | added | Winston Ewert | Wait, then why are your constructors bloated? | |
| May 4, 2016 at 10:10 | comment | added | R. Schmitz | @Winston It doesn't, but the children depend on several parts of the application (like the database models, the 3d model, the current selection of products etc.) | |
| May 4, 2016 at 9:56 | vote | accept | R. Schmitz | ||
| May 2, 2016 at 18:33 | comment | added | Winston Ewert | Why does application needs to depend on the dependencies of its children? | |
| May 2, 2016 at 17:48 | answer | added | radarbob | timeline score: 4 | |
| Apr 28, 2016 at 14:57 | comment | added | R. Schmitz | @PeterSmith That is similar to what I'm doing at the moment - but I'm still using global fields there. If you can give a small explanation of how to keep it testable in this situation, please put it into an answer and I'll mark it as answered. | |
| Apr 28, 2016 at 14:23 | comment | added | Peter Smith | @R.Schmitz the only thing that would be more singleton\global in that aspect would be the list of event listeners, although support for events are built into C# so then it's just a matter of registering the delegates. Typically the Mediator pattern would be used here in a singleton type fashion (either managed as a singleton through DI/IOC or directly a singleton). | |
| Apr 28, 2016 at 8:00 | comment | added | R. Schmitz | @PeterSmith Wouldn't that amount to the same? As in, I would then have to pass those events instead of the interfaces? | |
| Apr 26, 2016 at 17:12 | comment | added | Peter Smith | @R.Schmitz is there a reason why the 3d model doesn't listen for application-level events raised by the UI and respond to those instead of having some higher level component responsible for changing it? | |
| Apr 26, 2016 at 14:26 | history | edited | R. Schmitz | CC BY-SA 3.0 |
deleted 3 characters in body
|
| Apr 26, 2016 at 14:09 | comment | added | Robbie Dee | @R.Schmitz Yes, but you can use mocking frameworks without DI. To cut a long story short, interfaces are used widely outside DI. | |
| Apr 26, 2016 at 13:14 | answer | added | scorpdaddy | timeline score: 3 | |
| Apr 26, 2016 at 12:59 | comment | added | R. Schmitz | @DavidArno No, most of the files are under 200 lines even. The issue is more about otherwise isolated classes having to modify some 'global' parts, such as a 3d model and parts of the UI which e.g. calculate the total price. | |
| Apr 26, 2016 at 12:54 | comment | added | R. Schmitz | @RobbieDee ...which help you testing already injected dependencies. | |
| Apr 26, 2016 at 12:47 | comment | added | Robbie Dee | @R.Schmitz "...I can not see a situation where using an interface is not DI" - as I said: mocking frameworks... | |
| Apr 26, 2016 at 12:42 | comment | added | David Arno | Various remarks you make, eg "The application class was implementing 8 interfaces, and this was only roundabout a fifth of the products" suggest that the problem doesn't lie with DI, but with your design. It sounds like your classes are doing too much. Each class should only need to implement 1-2 interfaces to enable DI to glue everything together at run-time. Are any of your classes more than 3-400 lines long? | |
| Apr 26, 2016 at 12:18 | history | tweeted | twitter.com/StackProgrammer/status/724935562197622785 | ||
| Apr 26, 2016 at 12:01 | comment | added | R. Schmitz | I don't get your point. | |
| Apr 26, 2016 at 11:45 | comment | added | Robbie Dee | The interface-concretion arrangement is also a feature of mocking frameworks. They've also been in OO languages for a good few decades... | |
| Apr 26, 2016 at 11:42 | comment | added | R. Schmitz | @RobbieDee Yes, DI is about more, but I can not see a situation where using an interface is not DI. And if a singleton is not the preferred solution - which I also assume - then why is the preferred solution so messy? That is my main question, but I wanted to keep it open, as sometimes the general rule does not apply. | |
| Apr 26, 2016 at 11:13 | comment | added | Robbie Dee | Also, I've yet to see a problem where a singleton is the preferred solution. The canonical example people always seem to state is a log writer but even here you may want to write to a number of different logs (error, debug etc). | |
| Apr 26, 2016 at 11:07 | comment | added | Robbie Dee | DI isn't just about using interfaces, it is the ability to swap out concretions which is especially useful in the unit testing sphere... | |
| Apr 26, 2016 at 10:59 | review | First posts | |||
| Apr 26, 2016 at 11:37 | |||||
| Apr 26, 2016 at 10:49 | history | asked | R. Schmitz | CC BY-SA 3.0 |