You want to improve your code, and you find some inspiration when you read something like the Editing Code and Stories post, but you want something more actionable.
Editing Checklist
Use this checklist to edit code when you revisit it after some time - a week or so, then a month or two. Apply at the file/component level (class, subsystem, whatever unit of encapsulation you might have).
- Do you have test coverage you're comfortable with? You'll probably want to run unit tests if available as you go; catch up if needed.
- Start with the big picture. Is the code reasonable to understand, or do you need to reorganize things?
- If you're reorganizing things for understandability, consider refactoring for that purpose - to organize complexity.
- Know when to stop. You can timebox the process, or maybe you have a specific goal (clarify foo, get rid of blah).
- Remove unused code (leave a marker or comment in file history if useful).
- Remove unused dependencies (headers you don't need to compile, assembly references you don't need, namespaces/packages you don't use).
- Avoid repetition and consolidate where it makes sense.
- Remove comments that don't matter.
- Add comments that matter. Tables, references, state machine descriptions, "the lifecycle of blah", "how to use this class" are all good candidates.
- File bugs and tasks for things you'd like to follow up on.
Bonus Checklists
Steve McConnell has written quite a bit on software development, much of which has stood the test of time. Many of the checklists from Code Complete 2nd Edition have been collected by Matthew J. Miller and hosted here.
Happy editing!
Tags:
checklist coding
Home