Clean Code

  • Don't do big restructure, improve incrementally.
    • One of the berst ways to ruin a probem is to make massive changes in the name of improvement
    • Keep the system running at all times
    • Make a tiny change, then run the tests
  • Always check-in code a little better than it was before.
  • Testing: rspec, test_unit
  • Open/Closed Principal: open for extension but closed for modification - or - create a barrier between those things that change and those things that don't.
  • Professionals write tests first
  • Professionals cleanup code
  • Professionals know that the only way to go fast -- is to go well

Is it worth it to clean up code?

  • Bad code gets harder and harder to clean as time goes by.
  • You should clean code as soon as it gets messy.
  • This takes less time than debugging code later
  • Nothing has a more profound and long-term degrading effect than bad code:
    • Bad schedules can be redone
    • Bad requirements can be redefined
    • Bad team dynamcis can be resolved

Analogy: What is the quickets way to be done with dinner?

  • After dinnner, get up and walk away and don't clear or do the dishes
  • Or, keep the dishes clean all the time
  • Dinner will take longer, but the whole process of preparing dinner will be quicker

Links