﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-jokes000-随笔分类-Software Engineering</title><link>http://www.cppblog.com/jokes000/category/17984.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 25 Oct 2011 02:38:24 GMT</lastBuildDate><pubDate>Tue, 25 Oct 2011 02:38:24 GMT</pubDate><ttl>60</ttl><item><title>基于契约设计DBC(Designed by contract)</title><link>http://www.cppblog.com/jokes000/archive/2011/10/25/159030.html</link><dc:creator>Voices.</dc:creator><author>Voices.</author><pubDate>Tue, 25 Oct 2011 01:58:00 GMT</pubDate><guid>http://www.cppblog.com/jokes000/archive/2011/10/25/159030.html</guid><wfw:comment>http://www.cppblog.com/jokes000/comments/159030.html</wfw:comment><comments>http://www.cppblog.com/jokes000/archive/2011/10/25/159030.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/jokes000/comments/commentRss/159030.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/jokes000/services/trackbacks/159030.html</trackback:ping><description><![CDATA[&nbsp; &nbsp; &nbsp; 使用DBC，类的编写者显式地规定针对该类的契约。客户代码的编写者可以通过该契约获悉可以依赖的行为方式。<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;契约是通过为每个方法声明的前置条件和后置条件来指定的要使一个方法得以执行，前置条件必须要为真。执行完毕后，该方法要保证后置条件为真。<br /><br />&nbsp; &nbsp; &nbsp; 派生类的前置条件和后置条件的规则是：<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 在重新声明派生类中的例程时，只能使用相等或者更弱的前置条件来替换原始的前置条件，只能使用相等或者更强的后置条件来替换原始的后置条件。换句话说，当通过基类的接口使用对象时，用户只知道基类的前置条件和后置条件。因此，派生类对象不能期望这些用户遵从比基类更强的前置条件。也就是说，它们必须接受基类可以接受的一切。同时，派生类必须和基类的所有后置条件一直。也就是说，它们的行为方式和输出不能违反基类已经确立的任何限制。基类的用户不应被派生类的输出扰乱。<img src ="http://www.cppblog.com/jokes000/aggbug/159030.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/jokes000/" target="_blank">Voices.</a> 2011-10-25 09:58 <a href="http://www.cppblog.com/jokes000/archive/2011/10/25/159030.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>