What can you do to a legacy codebase that will have the greatest impact on improving the quality?

前端 未结 11 1287
既然无缘
既然无缘 2021-01-30 06:51

As you work in a legacy codebase what will have the greatest impact over time that will improve the quality of the codebase?

  • Remove unused code
  • Remove dup
11条回答
  •  轮回少年
    2021-01-30 07:40

    Add unit tests to improve test coverage. Having good test coverage will allow you to refactor and improve functionality without fear.

    There is a good book on this written by the author of CPPUnit, Working Effectively with Legacy Code.

    Adding tests to legacy code is certianly more challenging than creating them from scratch. The most useful concept I've taken away from the book is the notion of "seams", which Feathers defines as

    "a place where you can alter behavior in your program without editing in that place."

    Sometimes its worth refactoring to create seams that will make future testing easier (or possible in the first place.) The google testing blog has several interesting posts on the subject, mostly revolving around the process of Dependency Injection.

提交回复
热议问题