Rewrite or repair?

后端 未结 11 1756
北荒
北荒 2021-01-02 01:01

I\'m sure you have all been there, you take on a project where there is a creaky old code base which is barely fit for purpose and you have to make the decision to either re

11条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-02 01:43

    Just clean up the code a little bit every time you work with it. If there isn't one already, setup a unit testing framework. All new code should get tests written. Any old code you fix as a result of bugs, try to slide in tests too.

    As the cleanups progress, you'll be able to sweep more and more of the nasty code into encapsulated bins. Then you can pick those off one by one in the future.

    A tool like javadoc or doxygen, if not already in use, can also help improve code documentation and comprehensibility.

    The arguments against a complete rewrite a pretty strong. Those tons of "little bugs" and behaviors that were coded in over the time frame of the original project will sneak right back in again.

提交回复
热议问题