Friday, October 01, 2004
Static hell!
Where does it say that factories classes only should have static methods? Nowhere, but somehow it seems to be the rule. Why am I complaining about this, you may ask? After one week trying to reuse some of the legacy code at work (written one month ago :-) I am getting quite frustrated trying to write tests for the new functionality I am adding. But now, after a half day of refactoring the code, I have managed to get rid of the problem. For now…
Subscribe to:
Post Comments (Atom)
2 comments:
You should investigate using a proper IoC container, such as HiveMind. One of the beauties of HiveMind is that you never, ever, use static variables or methods. Your factories are objects that create other objects. The factories get created as needed, the are used to create other objects, as needed. Threadsafe, just-in-time ... it's all free in HiveMind (or Spring, etc.).
Yeah, you are right, and that is exactly the point I am trying to sell to my colleagues. I have got “permission” to use Spring Framework when developing a new service on our application, and that is exciting. At first we are mainly going to use the IoC part of the Spring Framework, but I think we also will going to use the JMS support as well. As I mentioned in my original posting we have a lot of legacy code, where the main part was NOT written one month ago.
Post a Comment