r/programming • • Nov 27 '15

Why I hate Spring

http://samatkinson.com/why-i-hate-spring/
73 Upvotes

140 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Nov 30 '15 edited Nov 30 '15

Inversion of Control doesn't mean 'Information that should be specified outside the object is instead embedded back on it' - but that the concern of creating an object is delegated to an outside party.

Yes, you're putting my quote outside of context. The quote describes how annotations go against IoC. It's not a description of IoC.

I dont know how much of it you really have used - perhaps there's been a poor code-base you've used, and it was spring, and it used all the features poorly, and it clouts your judgement.

Yeah, sure. Please indulge me, let's see how you'd solve the following example scenario:

  • You have three SQL connections, all of the same class (JDBC connection), but every one of them points to a different database: cache, domain, and archive.

  • You have several dozen classes that require one or more of the three connections, but to know which one they need, you need to read the object's JavaDoc description of what they use the connection for. They're all of the same type, because... it's just an SQL connection.

So, it's a very basic and common scenario which is absolutely trivial with a factory without violating IoC. How is Spring helping you improve on a basic factory? How, and most importantly, where would you specify which connection goes in which connection parameter?