Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can you have Singleton objects in VFP?
Message
De
09/07/2003 15:18:24
Joel Leach
Memorial Business Systems, Inc.
Tennessie, États-Unis
 
 
À
09/07/2003 09:57:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00808442
Message ID:
00808648
Vues:
16
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform