Inline or Precedure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have Code that can either be run inline or called as multiple procedures. What would be the best practice, I like the component model with procedures but heard that inline executes faster... Thanks in advance...

Also, why does calling dispose such as with any var.dispose execute faster then simply setting to nothing.

Which is faster

dim me as va
some cod
me = nothin

o

dim me as va
some cod
me.dispos
me = nothin

Thanks...
 
in-line code always executes faster that external calls to methods. however,
you should *always* design applications for maintainability...very few
occasions exist where that model of development will cost your application
time. w/o maintainability, you will *always* cost time...your customer's,
yours, and will eventually kill your app when it cost more to maintain than
the savings it originally afforded.

..net uses non-deterministic garbage collection in order to "know" when it
can release resources. setting an object to nothing in .net just helps the
gc better tell/determine that the object can no longer be reached/used...and
thereby can be killed off. disposing an object makes the gc look at that
object in a little different light...it has less to do in order to "know"
that no other referencing object can/has access to it.

hth,

steve


| I have Code that can either be run inline or called as multiple
procedures. What would be the best practice, I like the component model with
procedures but heard that inline executes faster... Thanks in advance...
|
| Also, why does calling dispose such as with any var.dispose execute faster
then simply setting to nothing..
|
| Which is faster:
|
| dim me as var
| some code
| me = nothing
|
| or
|
| dim me as var
| some code
| me.dispose
| me = nothing
|
| Thanks...
 
Hi Anthony,

Search this newsgroup than you will see that both that you use is called bad
code.
dim me as var
some code
me = nothing
This you use when a property has to be reused by instance with a
databinding. When it is a value it makes no sence at all because it is only
set to its default value, so setting an integer to 0 or a string to "" does
the same and gives a better idea that you do that for reusing it.

dim me as var
some code
me.dispose
This can only when there is a dispose method in a class and should than only
be used for unmanaged resources, however that is never for a value.
me = nothing
See above.

I hope this helps something

Cor
 
Little addition in the sentence
This can only when there is a dispose method in a class and should than only
be used for unmanaged resources, however that is never for a value.

(I placed later that unmanaged resource text in the middle)

now the end has to be.

A value has never a method, and therefore never a dispose.

Cor
 
* =?Utf-8?B?QW50aG9ueSBOeXN0cm9t?= said:
I have Code that can either be run inline or called as multiple
procedures. What would be the best practice, I like the component model
with procedures but heard that inline executes faster... Thanks in
advance...

Also, why does calling dispose such as with any var.dispose execute faster then simply setting to nothing..

Which is faster:

dim me as var
some code
me = nothing

or

dim me as var
some code
me.dispose
me = nothing

IMO you should not need to care about that, the JITter is/will
be/should be able to do inlining automatically when it makes sense.

To your 2nd question: Setting an instance variable to 'Nothing' is
different from calling its 'Dispose' method. Calling 'Dispose' will
clean up unmanaged resources used by the instance at the time of calling
the procedure.
 
Back
Top