views:

74

answers:

1

I want to create a "singleton-factory class" to retrieve my specialized objects. It is possible to create such a class and does it give me some performance surplus over a simpler solution like a static factory? Or are there any other solutions?

This class would be a key component of a data intensive application dealing with constant database access writes. Each specialized object would be called when the factory recognizes that it is needed to write a row in a table with a special pattern.

I'm not a performance expert but would like to tune the solution to be memory light, there's not a need for more that 1 factory across multiple threads dealing with specialized objects and I would like to implement some caching (to retrieve already created Specialized instances).

Solutions?

+2  A: 

Why not make this class using static fonctions ? No need of instanciating a factory.

Clement Herreman
That's what I thought about when I wanted it to be unique across multiple Threads, but I still miss some piece of the puzzle
Lex
What pieces of the puzzle ?
Clement Herreman
None, problem solved while writing this comment.! Your answer has proven useful.
Lex
It is my pleasure
Clement Herreman