Hello

As you might know there is a pattern called singleton, which is as class that can be instanced only once in the application. Every new instance of the class, is a reference to the unique object in memory. That mechanism is implemented in the constructor method.

Now, I would like to make a pattern to work with resources, that sometimes is a normal class and sometimes is a singleton. For example, if I have a model with certain filepath, when it is loaded for the first time, a new instance should be created. But when it is loaded again, the constructor should return the reference to the object already in memory.

By the moment I'm using functions to emulate this behavior. But sometimes it's hard to remember when I should use the global function or the constructor to load.

I think this is probably a work with the internals of OOP's mechanisms of Delphi, which I don't know enough. Any idea on how to do this will be greatly appreciated.