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

前端 未结 11 1285
既然无缘
既然无缘 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:35

    Late to the party, but the following may be worth doing where a function/method is used or referenced often:

    • Local variables often tend to be poorly named in legacy code (often owing to their scope expanding when a method is modified, and not being updated to reflect this). Renaming these in line with their actual purpose can help clarify legacy code.
    • Even just laying out the method slightly differently can work wonders - for instance, putting all the clauses of an if on one line.
    • There might be stale/confusing code comments there already. Remove them if they're not needed, or amend them if you absolutely have to. (Of course, I'm not advocating removal of useful comments, just those that are a hindrance.)

    These might not have the massive headline impact you're looking for, but they are low risk, particularly if the code can't be unit tested.

提交回复
热议问题