I've been working my way through your Spring 2.0 book and am able to see certain advantages of using Spring.
The learning curve is not one of them.
It also makes testing more of a pain in that you have to recreate all the Spring managed dependencies .
Does spring 3 provide any significant benefits over the previous versions ? I'm trying to decide whether it's worthwhile investing time learning Spring3 or whether it is just hype.
Joined: Jan 28, 2008
Well, I have to disagree on the testing part. Testing is actually made easier using spring, not harder. Significant benefits of spring 3.0 include simplifications to the MVC framework, task scheduling and configuration, along with the new Spring Expression Language and a lot of other stuff
Yea especially with stuff like which makes mocking a breeze ... and whats more its native to spring, so if an application is using spring, its really helpful.
Joined: Sep 19, 2003
Indeed, Spring doesn't make testing harder...it makes it easier.
When you use dependency injection and inject as interfaces, you make it so simple to simply create a mock implementation of those interfaces and wire them into the class you're testing. Keep in mind that in a unittest, your test is doing the wiring of the mocks...not Spring. Spring shouldn't be involved in a unit-testing.
For integration testing Spring can get involved...and for the most part you can (and should) use the same Spring configuration that you use in the production runtime. If there are some things you do *not* want to be real and need to be mocked during the integration test, then let Spring wire them. That's where breaking the context into multiple XML files comes in handy...you can use most of the same XML configs for most of the application...and substitute a test configuration for the parts that need to be mocked up.
One last thought...I said that interfaces make it easy to do mocking...that's true and there are a lot of other good reasons to use interfaces. But using a mocking framework such as Mockito makes it possible to mock out concrete classes. So the interface-oriented approach isn't strictly necessary for mocking...but it's still a good idea in many cases.