一次且仅一次(once and only once,简称OAOO)是面向对象编程中的一条基本原则,又称“一个规则,实现一次”(one rule, one place)。指的是由(人编写而非机器生成的)代码和测试所构成的系统必须能够表达所应表达的内容,但是不能含有任何重复代码。 其起源已经不可考,一般认为是因为极限编程方法的创始者之一肯特·贝克总结和宣传而使其广为人知。
“一次且仅一次”是极限编程的座右铭。
传输可靠性有类似的性能问题,但是其令人感兴趣的好处是一次且仅一次传送。
Transport reliability has similar performance concerns but the interesting benefit is once-and-only-once delivery.
比尔:你在《重构》一书中提到:“代码应该实现任何逻辑一次且仅一次,这是良好设计的要素”。
Bill Venners: in your book, Refactoring you say, "the code says everything once and only once, which is the essence of good design."
应用推荐