Friday, January 16, 2015

Class Factories and Factory Scopes

Misko Hevery seems to favor factories that perform the manufactoring process for all objects within an object lifetime. See http://misko.hevery.com/2009/03/30/collaborator-vs-the-factory/
This leads to aggregate factories for different scopes such as Application, servlet, Request, etc. I consider these to be equivalent to the IoC container as in Spring's ApplicationContext which is a  factory i.e. a BeanFactory.

But what about "small lifetime" objects which are the factories we usually think of as in the Factory Method pattern which create objects on the fly? This is broached to Misko by Giorgio Sironi at http://misko.hevery.com/2008/10/21/dependency-injection-myth-reference-passing/ regarding the creation of a TagFactory as "an example of creation of non-newables (Song example) in the application logic, that is simply delegation to the TagFactory" - alluding to http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/.

Surprising Misko didn't have much to say on it other than "I think you are on the right track."

No comments:

Post a Comment