Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DCOM VBA collection efficiency question

Status
Not open for further replies.

kenlars99

Programmer
Nov 26, 2003
1
DE
Hello all, I am using a COM object created in VB6 (using an activex exe, for the curious), and a number of methods on my classes return VBA collections. I am accessing the object via DCOM, and am trying to reduce the number of network calls.

let us say that the client performs an operation like:

MyObjA.ObjBCollection("name of a b object").ObjCCollection("name of a c object").MyProperty = "Property value"

where MyObjA.ObjBCollection is a collection of objects of type B, which have yet another collection of objects ObjCCollection of type C.

MyObjA is an object on the server that is being accessed by DCOM.

How many DCOM calls is this?

is it what I imagine to be the worst case:
1 to get ObjBCollection
+1 to get the specified element "name of a b object"
+1 to get the ObjCCollection
+1 to get the specified element "name of a c object"
+1 to set the property?
=5?

or is there some client-side caching/optimization that reduces this that I am not aware of?

Any insight appreciated,

Ken.
 
MyObjA resides on your server. It never leaves. Your client only gets the interface point to the object.
Every dot level requires a level of resolution. So I would expect the worst as
MyObjA.ObjBCollection("name of a b object").ObjCCollection("name of a c object").MyProperty
is really
MyObjA.ObjBCollection.item("name of a b object").ObjCCollection.item("name of a c object").MyProperty

additionally since you use String names for items there is step where that to must be resolved.

I never use collections across the network. Marshelling is a hog.
I never use properties across the netowk. Same reason.

If I have a large amount of data to pass accross like this then I normally use a recordset which has special marshelling code.

What is even worse is this situation

Collection lives on the server.
You create an obect on the client
You add the object to the collection on the server
you access the object via the collection on your client. you know what happens to that last call?
It ping pongs.

Object (by default) don't leave the machine where they are created. So any time you use a property, on a remote machine, of that object there is a DCOM call accross the network. Recordset physically copy a majority of the recordset object to the client redusing overall network traffic. This is why if you, in server code, you set the .sort property of a recordset and pass that recordset back to the client the .sort property will be empty. What does fully copy accross is the Fields collection and some other minor properties.

The normal collection object does not copy the collection across and even if it did the objects it contain still reside on the machine where they are created.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top