Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Design Pattern - Factory and Abstract Factory
Message
From
03/01/2006 17:14:05
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
03/01/2006 17:07:07
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01082705
Message ID:
01082916
Views:
23
>>>I wouldn't do that, because I'd rather have the oFactory handle the additional parameters and other possible hurdles of actual createobject() or newobject() code. I'd prefer the loWait=oFactory.create("tokennamehere")
>>>
>>>Since factory is such a lightweight class, you can instantiate it on the spot, in a local variable - then you won't have the datasession problem. Replace oFactory with loFactory in my examples, then.
>>
>>So, to be consistent, I could do this everywhere?
>>
>>m.loFactory = CreateObject(m.oApp.GetFactoryName())
>>m.loFactory.Create(m.cTokenName,m.cParameterList)
>
>Sure, why not? It's clean (even in design pattern terms), and it works. And as long as you keep your factory class thin (defined as custom in a .prg), this should be almost as fast as the old NewObject() itself.

Thanks! I'll let you know what I come up with. I am leaning towards having a private data session object that manages opening/closing the table. The factory itself will just access that object - prevents it from needing the open/close code etc.
Previous
Reply
Map
View

Click here to load this message in the networking platform