你应该多久重构一次? [英] How often should you refactor?
问题描述
几周前,我与一些同事讨论了重构问题,我似乎属于少数人认为尽早重构,经常重构"是防止代码变得混乱和无法维护的好方法.其他一些人认为它只是属于项目的维护阶段.
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 that keeps code from getting messy and unmaintainable. A number of other people thought that it just belongs in the maintenance phases of a project.
如果你有意见,请为它辩护.
If you have an opinion, please defend it.
推荐答案
就像你说的:尽早重构,经常重构.
Just like you said: refactor early, refactor often.
尽早重构意味着必要的更改在我的脑海中仍然记忆犹新.重构通常意味着更改往往更小.
Refactoring early means the necessary changes are still fresh on my mind. Refactoring often means the changes tend to be smaller.
延迟重构只会导致一团糟,这进一步增加了重构的难度.一发现乱七八糟的东西就立即清理,防止它堆积起来并在以后成为问题.
Delaying refactoring only ends up making a big mess which further makes it harder to refactor. Cleaning up as soon as I notice the mess prevents it from building up and becoming a problem later.
这篇关于你应该多久重构一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!