From: Tom C on
Just wondering, aside from readibility, is there any cost or benefit
to using the function declaration value as opposed to a dim value to
return the value of a function. It seems to be the 2nd perhaps
preferred method creates yet another object that has to be managed?

function x as object
x = something
end function

or

function x as object
dim o as object = something
return o
end function
From: Miro on
I would say that the second meathod you mentioned is the proper way.

funciton bla() as object
dim o as object = something
return o
end function

The only time I have seen the other being used is in old "Microsoft Access
Code" where the function name is actually the object.
To me, a function is a function, a sub is a sub, and a variable that
contains an object is a variable that contains an object.

I personally try to keep them seperate.



Miro

"Tom C" <tom_claffy(a)asdsoftware.com> wrote in message
news:b3f5b523-cfc2-43bf-b308-99b5eeb51b9b(a)l2g2000vbg.googlegroups.com...
> Just wondering, aside from readibility, is there any cost or benefit
> to using the function declaration value as opposed to a dim value to
> return the value of a function. It seems to be the 2nd perhaps
> preferred method creates yet another object that has to be managed?
>
> function x as object
> x = something
> end function
>
> or
>
> function x as object
> dim o as object = something
> return o
> end function

From: Tom C on
On Dec 16, 2:46 pm, "Miro" <m...(a)beero.com> wrote:
> I would say that the second meathod you mentioned is the proper way.
>
> funciton bla() as object
> dim o as object = something
> return o
> end function
>
> The only time I have seen the other being used is in old "Microsoft Access
> Code" where the function name is actually the object.
> To me, a function is a function, a sub is a sub, and a variable that
> contains an object is a variable that contains an object.
>
> I personally try to keep them seperate.
>
> Miro
>
> "Tom C" <tom_cla...(a)asdsoftware.com> wrote in message
>
> news:b3f5b523-cfc2-43bf-b308-99b5eeb51b9b(a)l2g2000vbg.googlegroups.com...
>
>
>
> > Just wondering, aside from readibility, is there any cost or benefit
> > to using the function declaration value as opposed to a dim value to
> > return the value of a function. It seems to be the 2nd perhaps
> > preferred method creates yet another object that has to be managed?
>
> > function x as object
> > x = something
> > end function
>
> > or
>
> > function x as object
> > dim o as object = something
> > return o
> > end function- Hide quoted text -
>
> - Show quoted text -

I am looking more for more memory impact and load than coding styles.
It is probably more readable the 2nd way but in a very large app, does
it have any impact on application. Does it create more gchandles,
cause more collection, etc...
From: Tom Dacon on

I am looking more for more memory impact and load than coding styles.
It is probably more readable the 2nd way but in a very large app, does
it have any impact on application. Does it create more gchandles,
cause more collection, etc...

Tom, eighty percent of the so-called optimization that programmers worry
about makes no perceptible difference in the performance of an application,
and this is a sterling example. If you want to make a difference, work on
your algorithms, not tiny code-generation issues like this.

Tom Dacon
Dacon Software Consulting


From: David Anton on
The first way is a terrible VB holdover from long ago - if anyone not very
familiar with VB has to maintain your code then they'll be scratching their
head over this VB-unique way of setting a value to return from a function.

You are also not saving any object creations using the legacy VB approach -
a hidden variable is created behind the scenes which VB causes the function
to return when it hits either an 'Exit Function' or 'End Function'.
--
David Anton
Convert between VB, C#, C++, & Java
http://www.tangiblesoftwaresolutions.com


"Tom C" wrote:

> Just wondering, aside from readibility, is there any cost or benefit
> to using the function declaration value as opposed to a dim value to
> return the value of a function. It seems to be the 2nd perhaps
> preferred method creates yet another object that has to be managed?
>
> function x as object
> x = something
> end function
>
> or
>
> function x as object
> dim o as object = something
> return o
> end function
> .
>