2 ms·
Food for thought: 1. As another responder mentioned, some of your examples sound more like named constants than global variables. 2. Not using global variable
by Chris_Newton 16y ago
Food for thought:
1. As another responder mentioned, some of your examples sound more like named constants than global variables.
2. Not using global variables is just an example of a more general rule: variables should generally have as small a scope as possible. The wider the scope, the harder it is for someone reading the code to understand how the variable is used, and the riskier it becomes to change that code.
3. 20K lines and 100 files is a small project, in the sense that one person can be familiar with all of it. While limiting scopes is still beneficial for readability on that scale, it really starts to pay off when there are multiple people working on a project and no one person knows the whole thing.
I see parallels with modular design generally here: although it is helpful even on quite small projects, you can get away without it up to a certain point. Beyond that point, you really start to suffer from having different parts of your system tied together in ad-hoc, uncontrolled ways.