Re: Execute Command Question by William
William
Thu Dec 18 10:27:12 CST 2003
the short answer is probably. There's no way to know how much garbage
collection is going to occur so technically speaking, that's not why it'd be
better. However, the fewer objects that are created, in general, the less
you would expect garbage collection, Instantiating objects has some
overhead while declarations don't have much at all. Where you can get into
real troulbe is when you are passing reference types all over the place....
With all that said, going for an approach where you have one adapter or a
few of them and you reuse them will probably yeild the best performance
"Rob Panosh" <rob_!!!NO!!!SPAM!!!_panosh@asdsoftadfdware.com> wrote in
message news:uxeRHmXxDHA.2356@TK2MSFTNGP12.phx.gbl...
> Bill,
>
> Thanks for the timely reponse. I currently have them defined as Private
> Dim's to the class, if they are nothing then I create them otherwise I
just
> reuse the adapter and command. I am assuming that I should get better
> performance this way because less command/adapter objects are created thus
> less garbage collection. Is that a correct assumption?
>
> Thanks,
> Rob
>
> "William Ryan" <dotnetguru@comcast.nospam.net> wrote in message
> news:eahDyKXxDHA.2520@TK2MSFTNGP10.phx.gbl...
> > It depends...if the class as a whole might have other methods that could
> use
> > these, then you may want to make them properties. If each time, only
this
> > method needs them, then you make want to amke the function Shared
(VB.NET)
> > or Static (C#) so that you don't have to instantiate an seperate
instance
> of
> > the class and just declare them locally.
> >
> > Once again, it really depends on your overall design, but if this is a
> > utility library, it may lend itself well to being a shared/static
member.
> > Also, even if you do go with the shared thing, you can still declare
them
> as
> > Shared/Static members and reference them from your method.
> >
> > HTH,
> >
> > Bill
> > "Rob Panosh" <rob_!!!NO!!!SPAM!!!_panosh@asdsoftadfdware.com> wrote in
> > message news:uzXVUDXxDHA.2084@TK2MSFTNGP09.phx.gbl...
> > > Hello,
> > >
> > > I have a sub, ExecuteCommand(), that I pass Insert, Update, and Delete
> > > commands to, Inside this sub I create a Command and DataAdapter
object
> > that
> > > executes the incoming command. The question I have is should I create
> > these
> > > objects as Local DIM's everytime the SUB is called or should I create
> them
> > > as Private instance variables of the class and reuse them?
> > >
> > > Thanks,
> > > Rob Panosh
> > > Advanced Software Designs.
> > >
> > >
> >
> >
>
>