Writing maintainable code

Jeremy picture Jeremy · Oct 2, 2008 · Viewed 10k times · Source

What is the single most important factor for writing maintainable code (language independent)?

Answer

Jim C picture Jim C · Oct 2, 2008

Write it for other people to read. This means a combination of good names, good comments, and simple statements.

Once upon a time memory was scarce and cycles times were slow. programmers were encouraged to write complex single lines of code that did many things. Today memory is plentiful and cycle times are fast. You should write 5 lines of simple code people can follow instead of one line they cannot understand.

Good comments don't have to be long, but they must be helpful.

Also be consistent. Do not change styles in your code. For example don't change naming styles from one section to the next.