Spring used to be confusing for me, largely due to the form of the comprehensive online documentation. The main issue with the docks is that the aim of the framework is not explained succinctly, and without intent it’s very hard to understand what’s going on with basically any piece of code.
Spring in Action gave me a powerful view of many of the frameworks in the collection of Spring frameworks, and drove the message home:
Spring was built to make Java Enterprise development easier.
With that in mind, I started seeing the pattern everywhere; it’s a very thoughtful collection of tools which I could grasp because, basically, I’d thought about implementing many of the different features for my projects at one point or another… even if joyously differently from what I’d had in mind.
Some of the key features in Spring:
- Dependency Injection is handled by a container – which is not a standard JEE container. This one had me for a while, as I groped for a way to get ahold of the application container. Developing your first Spring app for hosting in Weblogic (or any other application container) is bound to be confusing. Try the self-hosted approach first.
- Aspects! And implementation of many features with them. Aspects are mechanisms which allow you to write the code somewhere and have it splash everywhere – the sort of thing that would help you reduce the code for security, session management or logging. Some Spring features are implemented this way.
- Templates – another way to reduce boilerplate. Just hand over your tired, boilerplate ridden code and watch it be reduced to an expression of what you mean to do. It’s not UI templates or code templates like you’d use to stub a project. It’s behavior template, like the boilerplate we use all the time when working with JDBC.
One piece of Spring I found a massive hindrance to thorough learning is the pervasiveness of Spring Boot usage in the documentation. Having so many things be automatic is great for those who know what they’re about, but not so good for learning. I found Spring Boot akin to an IDE, and as now all the documentation refers to it… well, it’s not easy to piece everything together from the ground up anymore. All in all, a good tool – maybe I’ll write some small docs to help get started with it.