V2EX  ›  英汉词典

Postcondition

Definition / 释义

postcondition(名词):在计算机科学与软件工程中,指某个函数/方法/过程执行完成后必须为真的条件,用来描述“执行结果应达到什么状态”。(常与 preconditioninvariant 一起用于“契约式设计”。)

Pronunciation / 发音

/ˌpoʊstkənˈdɪʃən/

Examples / 例句

The postcondition ensures the list is sorted after the function returns.
后置条件确保函数返回后,列表已经被排序。

If the precondition holds and the implementation is correct, the postcondition should be satisfied even when edge cases occur.
如果前置条件成立且实现正确,那么即使出现边界情况,后置条件也应当被满足。

Etymology / 词源

由 **post-**(“在……之后”,源自拉丁语 post)+ condition(“条件”)构成,字面意思是“事后条件”,即“执行之后应成立的条件”。

Related Words / 相关词

Literary Works / 文学与著作例证

  • Object-Oriented Software Construction(Bertrand Meyer):系统讲解“Design by Contract”,常用 precondition/postcondition/invariant 来描述程序正确性要求。
  • Design by Contract, by Example(Richard Mitchell & Jim McKim):以示例方式使用 postcondition 来定义方法执行后的保证。
  • The Pragmatic Programmer(Andrew Hunt & David Thomas):在讨论断言与防御式编程时,会涉及与 postcondition 密切相关的思想(用条件检查保证结果正确)。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   823 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 22:58 · PVG 06:58 · LAX 14:58 · JFK 17:58
♥ Do have faith in what you're doing.