Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
NewObject or CreateObject or AddObject
Message
 
 
À
27/08/2007 17:20:22
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01250745
Message ID:
01250790
Vues:
13
>>>I was passing in an object, oHandler, to another object, oxServer, but decided I want to create oHandler inside oxServer instead, to keep everything encapsulated so references are easier to make. What decides when to use NewObject, CreateObject or AddObject? I was using CreateObject for oHandler, then passing it in, but what's the correct way to do it inside oxServer? Why?
>>
>>You use Newobject() and AddObject() methods to add objects (controls) to a container. An example would be adding label, button, etc. to a form during runtime.
>>The Newobject() and CreateObject() functions used to create object that do not belong to container but rather are refereced by it.
>
>So, NewObject can be used in either case. AddObject is only used with a container. CreateObject would be used in a non-visual, non-container class. I can use either NewObject or CreateObject in my case then. Why even have CreateObject if NewObject can do the same thing?

There is a long discussion going on on CreateObject vs. NewObject right now, started by Dragan N. You may want to read it.
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform