Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Are there tons of global variables?


I recently rewrote a flashing tool that was used for programming engineering samples (which there is an extremely limited supply of) and production equipment.

Literally everything (and I mean everything) in the old implementation was a global variable that would just be recycled throughout the runtime of the program. Excluding loop counters, you could count the number of localized variables on two hands. The call-and-response serial communication implementation was a pseudo-state machine scattered across a shitload of global variables, and it ran entirely in the UI thread. When variables didn't have useless names, they would often have the same name as another variable, just with the capitalization changed.

Software development is hell.


At my work it's a few hundred globals, often times used in a few hundred different places scattered over, again, hundreds of files.

To make things more fun there rarely is a function with less than a 1000 LOC, written in a Winforms Button_Click handler. Less than 10 functions I've seen take parameters and return a value, almost all rely on globals being set and set some themselves in return.

After the manager and main author of the software asked me to build a new UI and leave the underlying code untouched I decided to leave the company and work on someone elses messy code


How about returning a reference to a static variable that changes when the function is called with different parameters. [C++]

I can't imagine why he thought that was a good idea.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: