File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Help for Factory Design pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Help for Factory Design pattern" Watch "Help for Factory Design pattern" New topic

Help for Factory Design pattern

sunil antil

Joined: Jul 23, 2009
Posts: 20
Hi All

Can any one tell what is the meaning of the following line

The lifetime management of the generated objects must be centralised to ensure a consistent behaviour within the application

in context with factory method desgin pattern.


S.E Sunil Kumar
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3152

I think this query is similar to previous query you had posted.
Please continue in the previous thread if its same.

Mohamed Sanaulla | My Blog
sunil antil

Joined: Jul 23, 2009
Posts: 20
Hi Mohamed Sir

Its ok querry may be similar but I did not get answer of both of my querry. I will say thanks we some one sort out me from this problem.

Matthew Brown

Joined: Apr 06, 2010
Posts: 4543

It's difficult to tell exactly what was meant by a single quote with no context. But here's what I think it's getting at.

The clients that get objects from the factory cannot be responsible for managing the object's lifetime. Let's say that there's a cleanup method that needs to be called when the object is taken out of service. The client can't be responsible for this because it has no way of knowing whether the object is being shared with other clases, or whether it will be used again in the future. All this depends on what strategies the factory is using, and one point of the factory pattern is that clients don't need to know this.

So where can this "lifetime management" take place? It needs to be centralised somehow, probably in the factory itself.

(Here by "client" I just mean any classes that use the factory).

Does that help?
I agree. Here's the link:
subject: Help for Factory Design pattern
It's not a secret anymore!