Singleton and Prototype Standard

Asked

Viewed 52 times

0

I am developing a project where I came across the following situation: There are two families of algorithms that use a given object in different ways: the first just read the data and do a processing, the second modifies the object.

My problem is: this object that these families are extremely large and spend a lot of time to read the information in memory, so creating this object all the time will be a problem.

I know that for the family that only read the data, Singleton could be a solution and already for the family that modifies could use the prototype.

I was wondering if it is possible to combine these two patterns, because I’m using an abstract factory and I’m not sure if to determine which one to use at runtime (for each of the families).

  • Do you know which "template" each snippet of code would use? If yes, it can have different objects, each using a specific pattern.

  • Yes, I know. My question is whether I can specify this in the factory method of each of the families?

  • In this phrase "My problem is: this object that these families are extremely and spend a lot of time" it seems that some words have been missing. As to the question the ideal is to add code to exemplify your problem. If it is with a simplified version of your real code even better

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.