Six language-independent ways to write better code


  1. Plan for extensibility
    There are many simple suggestions that can help extensibility: Don’t code specific solutions — code generic, reusable libraries. Don’t assume the length or size of anything will be constant. Version all your user-data files. Use encapsulation.
    By far the most time spent in any stage of the software life-cycle will be spent in the maintenance phase — so it is imperative to design your software in a way that encourages easy maintenance — and that means designing for extensibility.
  2. Don’t use magic numbers
  3. Document why, not what
    If your code really needs a comment to explain what the code is doing, your code probably needs to be refactored or simplified, not commented.
  4. Don’t reinvent the wheel
  5. Work incrementally
  6. Find someone willing to criticize your work

Doing the right thing now will give you more time in the future to continue doing the right thing.