Creating a factory that returns singletons

Viewed 9301

I have common code (multiple class that I call controllers) that needs to be shared by multiple packages in the project. I was thinking of creating a factory, that returns these controllers. So, the factory would have a hashmap, that can return the controller asked for or create a new one if not created. The controllers have common code and since I don't need to create multiple instances of these controller, I think they should be singletons.

Does this seem like a good approach?

2 Answers
Related