How do you refactor?

前端 未结 14 1257
别那么骄傲
别那么骄傲 2020-12-13 03:06

I was wondering how other developers begin refactoring. What is your first step? How this process (refactoring) differ if you refactor code which is not yours? Do you write

14条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 03:11

    1. do not refactor anything non-trivial that does not already have unit tests
    2. write unit tests, then refactor
    3. refactor small pieces and re-run the tests frequently
    4. stop refactoring when the code is DRY* clean

    * DRY = Don't Repeat Yourself

提交回复
热议问题