Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CreateObject() vs NewObject()
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP1
Divers
Thread ID:
01249678
Message ID:
01250053
Vues:
25
I think you're too harsh on yourself. :)

Best wishes, had to run now to User Group meeting.



>Mike,
>
>While I agree with using a factory et all, I still do not like SET CLASSLIB nor SET PROCEDURE, for their scope is always global, thus you will most likely end with lots of procedure and class libraries open than are no longer required. Furthermore, now your objects are no longer "Isolated", for they depend on this global settings, what would happen if you happen to have a class defined in more than one class library / procedure without you not even knowing about it (for example using a third party class library)
>
>Anyways, my brain today is not working very well, I just gave a bad info in another thread, this might be just another one.
>
>>I often find myself wondering why we focus so hard on this level of detail. Best practice says we're supposed to make a component (UDF or class) to encapsulate design decisions of this kind.
>>
>>A factory object IMO (being the ultimate in flexibility) should be used to instantiate objects. It would be the place to decide if we should use newobject or createobject - as hardcoding classes limits flexibility.
>>
>>Further it would be a fantastic place to add code that checks to see if the class / procedure is already opened before opening it again.
>>
>>IF NOT "VCXNAME" $ SET("CLASSLIB")
>> SET CLASSLIB TO VCXNAME ADDITIVE
>>ENDIF
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform