This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Spring or your own factory? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Spring or your own factory?" Watch "Spring or your own factory?" New topic

Spring or your own factory?

Bob Lawson
Ranch Hand

Joined: Jul 20, 2010
Posts: 34
Spring is great and I use it a lot. But when I have a lot of object wiring to do, Spring can get cumbersome. Also, some of your business logic actually ends up in the config file rather than code. This is because when you abide by the single responsibility principle and divide up responsibilities into separate, the business rules are driven out of the code and into relationships between the classes. I find that doing the wiring in my own factory using good old java code is sometimes easier to understand than reading the xml, which can get pretty crazy.

Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
Starting with Spring 3.0 JavaConfig comes bundled together. Prior to that, it was a standalone extension. The configuration comes in plain Java classes with annotations but the annotations are only in the configuration classes, not in the beans themselves - this way people who hate adding third-party annotations can extract the config classes to a separate module, for example. If you worked with Guice, this is kind of similar to its Modules.
I really suggest you take a look at this old / new feature.
Bob Lawson
Ranch Hand

Joined: Jul 20, 2010
Posts: 34
Thanks for the info - I did not know about that. Sounds like just what I'm looking for. I will certainly give it a try!
I agree. Here's the link:
subject: Spring or your own factory?
jQuery in Action, 3rd edition