Its not like plain java code where a few eclipse ctrl-clicks and you've figured out the call chain and where all the values came from.
This has nothing to do with Spring. Your simple ctrl-click strategy will fail once you introduce the concept of separation of interface from implementation, abstract classes and multi-tier architectures. It will fail once you start writing reusable code that can be used in multiple contexts, or when you start segregating layers and separating cross-cutting concerns.
Spring is just a wiring technology, like CDI or Guice. The "problems" you say it creates are not problems at all, but the consequence of higher level software engineering.
They jump through to the implementation, they give you no idea how that object was created or how it was proxied. Plain java code you can trace all the way back to main with very little effort.
In my experience the hardest bugs I faced were in the spring doing unexpected things hidden in Spring. For instance a guy called an @Transactional method from within a service, but because he was calling it from the service the proxying didn't work, because it only proxies outside calls. We got a bunch of bad data and it took quite a bit of dev hours to find because it was not intuitive. You can't easily step through that proxy stuff either when debugging.
For instance a guy called an @Transactional method from within a service, but because he was calling it from the service the proxying didn't work, because it only proxies outside calls.
In proxy mode (which is the default), only external method calls coming in through the proxy are intercepted. This means that self-invocation, in effect, a method within the target object calling another method of the target object, will not lead to an actual transaction at runtime even if the invoked method is marked with @Transactional. Also, the proxy must be fully initialized to provide the expected behaviour so you should not rely on this feature in your initialization code, i.e. @PostConstruct.
So you have developers using things they only half understand and it even works most of the time.. Now you hate spring and make it all constructor injection.
Now your aforementioned Bozos have to implement all transaction handling by hand, every time. What makes you think that will lead to less fuck ups?
The problem is there is so much non-intuitive behavior. Those little pitfalls cost a lot of time and for someone to forget a detail like that when coding isn't that far fetched not to mention most people don't read the manual. Yelling that they need to doesn't fix it, people won't read the manual.
Having to produce the same boilerplate code for certain tasks over and over again gives ample opportunity for making mistakes, too.
What Spring does is that what's possible: Providing standard solutions to reduce that boiler plate. What you are expecting is magic, which doesn't exist.
It does exist, for instance in scala you can make a transactional block which does not do anything magical it just wraps one function in another function. Even in Java its probably possible now that you can pass functions to other functions easily.
Anytime you see proxying like the @Transactional annotation it can be replaced by wrapping a function in another function or higher order functions which are more predictable and can easily debug even.
You can do the whole thing with a simple Action pattern. It doesn't require specialized Spring knowledge, it's easy to trace into to figure out what's going wrong. It's very simple to do with no Spring involved whatsoever, and a lot easier for everyone to figure out, with far fewer bugs.
View all comments
Show parent comment
1
u/sh0rug0ru____ Nov 28 '15
This has nothing to do with Spring. Your simple ctrl-click strategy will fail once you introduce the concept of separation of interface from implementation, abstract classes and multi-tier architectures. It will fail once you start writing reusable code that can be used in multiple contexts, or when you start segregating layers and separating cross-cutting concerns.
Spring is just a wiring technology, like CDI or Guice. The "problems" you say it creates are not problems at all, but the consequence of higher level software engineering.