Spartan programming
The discipline of spartan programming means frugal use of variables:
- Minimize number of variables. Inline variables which are used only once. Take advantage of foreach loops.
- Minimize visibility of variables and other identifiers. Define variables at the smallest possible scope.
- Minimize accessibility of variables. Prefer the greater encapsulation of private variables.
- Minimize variability of variables. Strive to make variables final in Java and const in C++. Use annotations or restrictions whenever possible.
- Minimize lifetime of variables. Prefer ephemeral variables to longer lived ones. Avoid persistent variables such as files.
- Minimize names of variables. Short-lived, tightly scoped variables can use concise, terse names.
- Minimize use of array variables. Replace them with collections provided by your standard libraries.

Leave a comment