Information générale
Catégorie:
COM/DCOM et OLE Automation
>Suppose I have several business COM objects that use the same class to perform data services. Is there a way to create the object once and share it among the various business objects? I could set a property on the business object after I instantiate it, but then it wouldn't be stateless. I really don't want to pass the reference in as a parameter to every method. Does anyone do this, or is it typical to create a new data object for each business object? That seems like a waste.
>
>Thanks.
From what you say, I would create a new instance for each business object.
You are able to create it once, then assign it to each of the objects as properties, but then you loose some of the encaspsulation (ie the object is relying on another process to set it up correctly)
I dont think it is much overhead to just create a new property, and on init create the object and assign it.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement