Crazy Bob wrote about how he doesn’t get Spring, which was obviously going to get a lot of attention ;)
I see a lot of value in Spring, from projects in which I use it on. As you go from project to project, you tend to bring with you code from past projects. This may be a
StringUtil, a bunch of other old code, or 3rd party libraries.
Spring is an item that tends to join me across Java projects that follow particular conventions.
This isn’t because Spring is so amazingly different that it changes everything I do. It is because it does things that I could do but don’t want too.
- Dependencies: Yup, I could use Pico, or another DI framework, or my own thing. Spring happens to have the most features of the bunch though, and works nicely
- Testing: I tend to wire up all of my tests via Spring. I slap in a different test bean config, and it all gets slurped up for tests, making it zero work to wire in my tests
- Non-XML: You don’t have to use XML to wire up Spring. You can even use Ruby if you want ;)
- Wrapper functionality: Spring is part DI, part wrapper libraries to make life easier. These guys went through the various frameworks and made them easier to use. Spring-Hibernate wrappers, JDBCTemplate, JTA stuff, you name it there is a Spring wrapper that makes things easier to use.
- Business logic: I want to write business logic. I don’t want to rev my own DI framework, and other infrastructure crud. Think about the man-hours that have been put into Spring. The testing that has been done so it works across domains. Why would I want to do this myself when I can have others do it.
- AOP: The simple Spring-AOP interceptors are simple, but now with AspectJ integration you have the power of AOP at your fingertips
It’s there. It works well. It is developed and tested by others. It means that I write less code. Why wouldn’t I use it?
Interestingly, in my current non-Java projects I don’t feel the need for this type of framework since I don’t have the complexity of the world of Java.