Use of public variables vs. passing arguments

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

Guest

There are situations in which I can declare a public variable as one option,
or I could pass arguments directly back to a calling subroutine as a second
option.

I know some of the decision-making is in programming style, necessity based
on how and where variables are needed, etc. But, setting those considerations
aside, is there any performance gain (or loss) using one over the other?

Does having 60 to 100 or more public variables help or hurt your processing
speed, or does it not make any difference?

I would really like a good answer to this as I may well shape my future
programming style around your input. Thanks much in advance for your
consideration and assistance on this.
 
As a performance difference public variables would have a very marginal
advantage. They only need to be created once. Local variables are created and
destoyed for each call. This is part of the reason for inlining your code
(minimizing the number of subs and procedures). That having been said the
performace gain will be extremely marginal (almost non existent). WHERE EVER
HUMANLY POSSIBLE AVOID PUBLIC VARIABLES. They can make debugging extremely
difficult. Multiple routines changing the value make it very difficult to
know at any given time what the value might be.

HTH
 
Back
Top