3 ms·
Well said :) . Spring looks so much as to show how useful ideas can be misapplied with catastrophic results. For example, liberate encouraging of dependency inj
by avmich 6y ago
Well said :) . Spring looks so much as to show how useful ideas can be misapplied with catastrophic results. For example, liberate encouraging of dependency injections leads to multitude of interfaces which are only ever implemented once by a production code class, and maybe one more time by a test class, even though Java has all methods virtual and testing could be done without requiring the interface.
- mamon 6y ago>> Java has all methods virtual and testing could be done without requiring the interface. Not sure what you mean by that. I thought that interface/implementation divide is the way to implement virtual calls. Unless you want testing frameworks to do bytecode instrumentation.
- nitrogen 6y agoModern testing frameworks can indeed mock concrete classes, which beats the bytecode generation that Spring would be doing anyway.
- avmich 6y agoIf your interface is going to be implemented by just one class, I'd offer to skip interface - it reduces amount of code. If you still need to pass, as a parameter, a class A in order to test a class B, you can instead pass class C inherited from A, with all necessary methods overloaded. If you just create a class A in java, no interfaces involved, class A will have its methods virtual. I'm not sure what do you mean by interface/implementation divide.
- oftenwrong 6y agoIt's reasonable to provide a single implementation of an interface, if the goal is to facilitate dependency injection for that component. The problem I find with Spring is that it is designed for dependency injection at all levels of its architecture, leading it to be one of the ultimate examples of Ravioli Code. https://wiki.c2.com/?RavioliCode https://wiki.c2.com/?RavioliCode DI is a powerful concept, but Spring projects rely on DI in such a generic way that it often doesn't even make sense for your application. You have to gain intimate knowledge of the abstractions, and inject a bunch of code in a bunch of places just to make it do the very-straightforward thing you were trying to do.
- avmich 6y ago> It's reasonable to provide a single implementation of an interface, if the goal is to facilitate dependency injection for that component. You don't really need dependency injection if there is only single choice of what to inject. You can just refer in code to the only possible component.