加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 3 – 承诺函数规则

发布时间:2020-12-16 09:35:10 所属栏目:百科 来源:网络整理
导读:我需要帮助记住我从中读到的这本书,它可能是有效的C或其他东西,但我不记得了.我正在阅读的内容基本上表明功能有3个承诺: 验证输入参数以确保它们满足预期的输入要求 保证尊重和尊重保持不变量 验证输出参数(返回和输出参数) 这本书也有一些很好的名字,但对
我需要帮助记住我从中读到的这本书,它可能是有效的C或其他东西,但我不记得了.我正在阅读的内容基本上表明功能有3个承诺:

>验证输入参数以确保它们满足预期的输入要求
>保证尊重和尊重保持不变量
>验证输出参数(返回和输出参数)

这本书也有一些很好的名字,但对于我的生活,我不记得了.很困扰我,我不得不来到Stackoverflow,看看是否有人认识到这一点并帮助我记住……

解决方法

概念的名称是 Design by Contract:

  • Expect a certain condition to be guaranteed on entry by any client module that calls it: the routine’s precondition—an obligation for the client,and a benefit for the supplier (the routine itself),as it frees it from having to handle cases outside of the precondition.
  • Guarantee a certain property on exit: the routine’s postcondition—an obligation for the supplier,and obviously a benefit (the main benefit of calling the routine) for the client.
  • Maintain a certain property,assumed on entry and guaranteed on exit: the class invariant.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读