How often should you refactor?

前端 未结 25 2295
耶瑟儿~
耶瑟儿~ 2020-12-13 01:36

I had a discussion a few weeks back with some co-workers on refactoring, and I seem to be in a minority that believes \"Refactor early, refactor often\" is a good approach t

25条回答
  •  庸人自扰
    2020-12-13 02:29

    I refactor code as soon as it's functional (all the tests pass). This way I clean it up while it's still fresh in my mind, and before anyone else sees how ugly the first version was.

    After the initial check-in I typically refactor every time I touch a piece of code. Refactoring isn't something you should set aside separate time for. It should be something you just do as you go.

提交回复
热议问题