| Author |
Static and Global variables
|
Raj Waters
Ranch Hand
Joined: Apr 21, 2002
Posts: 37
|
|
Static variables Is performance bottleneck OR performance enhancement? Global vairables Is performance bottleneck OR performance enhancement? yup - Raj
|
- Raj<br />[MCSE, SCJP, SCWCD]
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
Moving to performance forum...
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Originally posted by Raj Waters: Static variables Is performance bottleneck OR performance enhancement?
It probably doesn't make enough of a difference to care about. When would a static variable be exchangeable for a non-static one anyway???
Global vairables Is performance bottleneck OR performance enhancement?
Again, it probably doesn't make a difference. What is much more important is that global variables are a *design*/*maintenance* bottleneck. See http://c2.com/cgi/wiki?GlobalVariablesAreBad
|
 |
Raj Waters
Ranch Hand
Joined: Apr 21, 2002
Posts: 37
|
|
Hi Ilja The article about global variables was good. My concern is: Can it be related with performance? I guess if you have too many global variables, the program performance is relatively good. I mean I am not sure whether it logical to relate performance with global variables
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Originally posted by Raj Waters: My concern is: Can it be related with performance? I guess if you have too many global variables, the program performance is relatively good.
Why would that be?
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
And what's a "global variable" anyway? Java doesn't really have them. Are you talking about static variables (compared to instance variables), instance variables (compared to local variables or parameters), or what?
|
"I'm not back." - Bill Harding, Twister
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
I understood them to be "public static" - it's as global as a variable can get in Java. Might be wrong, of course... :roll:
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
Yeah, but since he also asks about static as a separate question, I thought it best to ask.
|
 |
Raj Waters
Ranch Hand
Joined: Apr 21, 2002
Posts: 37
|
|
Lets start with public static variables. Lets say in our application we have some public static variables declared to be used globally. These variables can be referenced using the class names and can be done so by all the components of an application, Now: Does it mean that the application can perform relatively fast if it has to access such static variables than instance variables. i.e. if these variables are redefined as instance variables, will it make a difference.
|
 |
 |
|
|
subject: Static and Global variables
|
|
|