The standard solution if you need short-lived or dynamically created objects is to use an injected Abstract Factory.
Showing posts with label Factories. Show all posts
Showing posts with label Factories. Show all posts
Thursday, May 24, 2012
Abstract Factory
Static vs. Abstract Factory
The key idea of static factory method is to gain control over object creation and delegate it from constructor to static method. The decision of object to be created is like in Abstract Factory made ouside the method (in common case, but not allways). While the key (!) idea of Factory Method is to delegate decision of what instance of class to create inside Factory Method. E.g. classic Singleton implementation is a special case of static factory method.Grygoriy Gonchar -http://stackoverflow.com/questions/929021/what-are-static-factory-methods-in-java
Friday, May 4, 2012
Factories
But still the creation logic is kind of separate from the rest of the logic as it’s only needed during creation time and not during the rest of the lifecycle of an object. Thus when creation logic gets complex enough, like calling repositories, you should spinoff this separate concern to another object, a factory object.http://programmers.stackexchange.com/questions/70734/ddd-a-rookies-unanswered-questions
Subscribe to:
Comments (Atom)