主页

索引

模块索引

搜索页面

三次法则

名称: 三次法则 The Rule of Three

备注

  Don Roberts 给了我一条准则:第一次做某件事时只管去做;第二次做类似的事会产生反感,但无论如何还是做了;第三次再做类似的事,你就应该重构。事不过三,三则重构。(Three strikes and you refactor)——《重构:改善既有代码的设计》

备注

It states that you are allowed to copy and paste the code once, but that when the same code is replicated three times, it should be extracted into a new procedure. The rule was introduced by Martin Fowler in his text “Refactoring” and attributed to Don Roberts.

主页

索引

模块索引

搜索页面