View Single Post
  #7   Spotlight this post!  
Unread 24-01-2007, 15:13
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Why Static Variables?

I actually wouldn't worry about static variables too much. They are an optimization that is rather easy to apply later.

Always optimize for readability.

Always be prepared for the MacTruck Event. (explicitly, a person ((you)) gets removed from play, typically with out warning).

I had to take over programming in my sophemore year of high school when our programmer suddenly could not attend competition. A few premature optimizations left the drivetrain code completely unreadable. I eventually had to kill that part and start over.

Static variables are NO WHERE NEAR that level of confusing, but just keep in mind that other people will read the code. If an optimization took you a decent amount of time to figure out, it will take even longer for the reader to.

Therefore, use local variables where it is good to do so. If you want to make it faster later, just type static in front of their declarations. I would hope the compilor would do that for you, but this ain't the brightest light in the box.