Coding Horror: Spartan programming

| | No TrackBacks

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.

No TrackBacks

TrackBack URL: http://www.iwebthereforeiam.com/cgi-bin/mt/mt-tb.cgi/1341

Leave a comment

Verification (needed to reduce spam):

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.32-en

About this Entry

This page contains a single entry by Hugh Brown published on December 4, 2008 7:29 PM.

Benefits of writing unit tests first was the previous entry in this blog.

Boston.com: News stories in photographs is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.