How to restrain one's self from the overwhelming urge to rewrite everything?

后端 未结 20 726
遥遥无期
遥遥无期 2021-01-30 12:50

Setup

Have you ever had the experience of going into a piece of code to make a seemingly simple change and then realizing that you\'ve just stepped into a wasteland tha

20条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 13:40

    The impulse to rewrite is righteous, provided that:

    • you "freeze" the existing code (with a label)
    • you start the rewrite attempt in a separate branch
    • you prepare first some unit-test in order to ascertain the current behavior and make sure you reproduce the existing features...

    That said, you have to balance the rewriting process with the measure stability of the legacy code.
    "If it is not broken, do not fix it" ;)

提交回复
热议问题