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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conn ByRef into Object - is this a good OOP practice

Status
Not open for further replies.

question4u

Programmer
May 27, 2005
1
IN
I would like to pass in an ADODB Connection object ByRef into my COM object instead of passing a connection string and having the processing overhead of opening a DB connection for each insanitation/initialization of an object.

Your thoughts?
 
I would, without thinking. Not saying that makes it good practice.



Wil Mead
wmead@optonline.net

 
I think the important question is how do you want the interface to your COM object to be? How do you want to use it? If you don't mind creating a connection before you can use it, (or if that's more appropriate for the function of the COM object) then by all means pass it a connection. As far as overhead, if you're going to pass a connection to every COM object that gets created then there's no real difference at the DB level because each connection will have to query the DB just like each instance of the COM object would. However, if the COM object is running on the server and instances are created on the client, it's probably better to let the client create the connection and save on server recources.

Hope that makes sense... :/

~Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
I would also add that you will want to make sure that you are not passing the object across and process baoundaries and/or machine boundaries. This will kill performance as will as cause security issues. If the object is to be passed around in a single process, then you will be fine. - Jeff Marler B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top