October 2004
Intermediate to advanced
240 pages
6h 22m
English
Avoid scope bloat, as with requirements so too with variables: Variables introduce state, and you should have to deal with as little state as possible, with lifetimes as short as possible. This is a specific case of Item 10 that deserves its own treatment.
Variables whose lifetimes are longer than necessary have several drawbacks:
• They make the program harder to understand and maintain: For example, should code update the module-wide path string if it only changes the current drive?
• They pollute their context with their name: As a direct consequence of this, namespace-level variables, which are the most visible of all, are also the worst (see Item 10).
• They can’t always ...
Read now
Unlock full access