54

“Don’t comment bad code—rewrite it.”
—Brian W. Kernighan and P. J. Plaugher

Comments
  • 1
  • 1
    I would personally do both
    1. try to understand it
    2. document it, write comments
    3. Write unit tests if possible.
    4. Rewrite the code

    Chances are that the code to rewrite is quite big and it's never simple to do so. In other words, you will introduce bugs by doing it. Worrying comments is much safer and faster and writing unit tests will somewhat reduce the amount of bugs you will introduce while refactoring.
Add Comment