Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OLEDragDrop Error when calling a Method List_Move()
Message
From
25/07/2001 13:34:30
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00533269
Message ID:
00535194
Views:
13
Mike-

>While I have you, what's the difference between CreateObject and NewObject?
>
>I ask because usually i create an object (like in my above problem) and call methods off of that created object, using CreateObject. Why/when would I want to use NewObject, instead?

Are you using at least VFP 6.0? If not then you won't see NewObject. But NewObject let's you specify the library the class is in, which means you don't have to keep track of SET CLASSLIB.

Some people benchmarked NewObject vs. SET CLASSLIB ; CREATEOBJECT and found it be significantly slower. But for me, NewObject is self-documenting and eases maintainability, and so the trade-off is worth it. Plus I try to not do so much objet creation that it becomes a bottleneck.

I'm hopeful that the VFP team will optimize the command when they can. FWIW, I haven't benchmarked it in VFP 7. Gee. Maybe I should? *g*
#DEFINE LOOPS 5000
LOCAL lo, lni, lnSeconds

CLEAR 

? "   Test for NEWOBJECT: "
lnSeconds = SECONDS()
FOR lni = 1 TO LOOPS
	lo = NEWOBJECT( 'MyTest', 'Temp.PRG' )
NEXT lni
?? SECONDS() - lnSeconds

? "Test for CREATEOBJECT: "
lnSeconds = SECONDS()
FOR lni = 1 TO LOOPS
	SET PROCEDURE TO Temp.PRG
	lo = CREATEOBJECT( 'MyTest' )
NEXT lni
?? SECONDS() - lnSeconds

DEFINE CLASS MyTest AS Session
	MyProp = "Hello!"
ENDDEFINE
Hm. Not so bad.
Previous
Reply
Map
View

Click here to load this message in the networking platform