按契约设计

Design by Contract

Bertrand Meyer

4人推荐
9位读者提及
20次提及

Hacker News 上怎么说

  • Eiffel 支持循环不变量(loop invariants),例如参见:http://se.ethz.ch/~meyer/publications/methodology/invariants... 另外也可以看看 Meyer 写的关于契约式设计(Design By Contract)的书,就算你以后压根不用 Eiffel 也该读读——绝对是块宝。

    Eiffel has loop invariants, for example see: http://se.ethz.ch/~meyer/publications/methodology/invariants... Also see Meyer's Design By Contract book, which you should read even if you will never use Eiffel - it's a gem.

  • 也可以读读 Robert Floyd 的论文《Assigning Meanings to Programs》。领会了上述核心思想之后,再去读 Bertrand Meyer 的《Design by Contract》和《Applying Design by Contract》,就会彻底搞明白怎么把这些思想应用到“真实”系统中去。

    Also read Robert Floyd's paper Assigning Meanings to Programs. After getting the gist of the above, reading Bertrand Meyer's Design by Contract and Applying Design by Contract will clarify on how to apply the ideas to "real" systems.

  • ……只要针对给定的语言和平台搭建好 tooling,这一切都能做到。静态类型只是形式化规范(formal specifications)的一个子集。我建议用后面这个词,这样他们能搜到更多有意思的干货。Meyer 的契约式设计(Design-by-Contract)算是一个门槛较低的做法,基本上在任何语言里都能搞。

    …can do all that if you build thetoing for given language and platform. Static typing is a subset of formal specifications. I suggest using the other phrase so they find more interesting stuff. Meyer's Design-by-Contract is an easy one you can do in basically any language.

  • Bertrand Meyer 的论文《Applying Design by Contract》展示了 DbC 究竟该怎么用。在“release”发布模式下,默认只开启前置条件(preconditions)就够了,其他都是可选的。我的经验法则是把所有的前置条件/后置条件/不变量……

    The paper "Applying Design by Contract" by Bertrand Meyer shows how DbC is to be used. It is sufficient to have only preconditions turned on by default in "release" mode, others are optional. My thumb rule is to have all preconditions/postconditions/invariants…

  • ……程序正确性的设计构件。因此,它是一种系统化(也就是非 ad-hoc、非随手乱写)正确使用断言(asserts)来保证程序状态的方法。强烈建议去读读 Bertrand Meyer 的论文《Applying Design By Contract》和《Design by Contract》。绝对值得每位程序员花时间看一看。

    …program correctness design constructs. Thus it is a systematic (i.e. not ad-hoc) way of using asserts correctly to guarantee program state. I highly recommend reading Bertrand Meyer's papers "Applying Design By Contract" and "Design by Contract". They are well worth every programmer's time.

  • 友情提示:上面 DbC 的维基百科页面里有个链接,指向 Bertrand Meyer 写的论文《Applying Design by Contract》,想学用法的话这篇论文是必读之作。

    PSA: The above DbC wikipedia page contains a link to the paper Applying Design by Contract by Bertrand Meyer which is THE paper to read to learn usage.

正在加载完整评论……

键盘快捷键

/
聚焦搜索框
j / k
下一本 / 上一本
Enter
打开选中的书
Esc
关闭 / 返回
g h
回到首页
g b
值得读精选
g t
历史总榜
g r
上升最快
g l
我的书架
?
显示本帮助