Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can you have Singleton objects in VFP?
Message
From
09/07/2003 15:18:24
Joel Leach
Memorial Business Systems, Inc.
Tennessee, United States
 
 
To
09/07/2003 09:57:03
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00808442
Message ID:
00808648
Views:
15
>Yes, I was thinking of having a class that could return references to it's own instances of the required classes.
>
>Thanks
>
>Kev
>

I remember someone trying this before (maybe José), and it couldn't be done inside the class. The problem was that returning anything besides .F. from Init(), such as the existing object reference, caused a new object to be created.

You could probably create a Singleton() function that would either return an existing instance (using AInstances()) or create a new one. Then your object creation would look something like:
loMyObject = Singleton("MyClass", "MyClassLibrary")
Not as good as the actual design pattern, but it might work for you.
Joel Leach
Microsoft Certified Professional
Blog: http://www.joelleach.net
Previous
Reply
Map
View

Click here to load this message in the networking platform