What is refactoring and what is only modifying code?

后端 未结 10 928
Happy的楠姐
Happy的楠姐 2020-12-12 13:18

I know that refactoring is \"changing the structure of a program so that the functionality is not changed\". I was talking with some of the guys I\'m working with on my fina

10条回答
  •  死守一世寂寞
    2020-12-12 14:00

    If the interface to a piece of code changes, then I consider that more than refactoring.

    The typical case for refactoring is

    • "Oh, all my unit tests run, but I think my code could be made cleaner"
    • Change code to be more readable / clearer / efficient
    • Re-run unit tests (without changing the tests) and check they still work

    This means that the term refactoring is relative to the interface you are discussing. i.e you could be refactoring the code behind one interface, while more extensively changing the code of another at a lower level (maybe that distinction is what's providing the confusion between you and your colleagues here?)

提交回复
热议问题