• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Spring 3 in Action

 
Ranch Hand
Posts: 579
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 unit test, 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.
 
Happily living in the valley of the dried frogs with a few tiny ads.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic