Re: from Danny's chat - 11/19

From: Jarle Stabell (jarle_at_remove_stuff_dlogikk_spam_kills_email.com)
Date: 12/21/04


Date: Tue, 21 Dec 2004 21:11:17 +0100

John Jacobson wrote:
> "Kevin Berry" <kevin@berry_REM0VETH1S_ware.com> wrote in message
> news:41c83da1$1@newsgroups.borland.com...
>> Captain Jake wrote:
>>> Design by contract results in a nice clean syntax when it is built
>>> into the language, but it isn't anything you can not implement
>>> using asserts.
>>
>> One of the benefits of DBC is that unit testing can be automated
>> better. If you have a set of pre and post-conditions you can have
>> some kind of automated tool that uses this information to generate
>> test cases. At least that's the way I understand it. I've never
>> used DBC in practice so it's all just theory to me, but the theory
>> sounds good...
>
> This all sounds like something you would never want implemented in a
> release version. I can imagine the user delight upon encountering a
> cryptic error message like "Precondition x > 300 violated".

The alternative is undefined behaviour (which can result in your user
loosing valuable data), or (if you're lucky) your user getting an access
violation. With an assertion failure, a bug is "outed" and your user can
tell you the line number the problem was spotted.

Cheers,
Jarle



Relevant Pages

  • Re: from Dannys chat - 11/19
    ... >> One of the benefits of DBC is that unit testing can be automated better. ... >> automated tool that uses this information to generate test cases. ... internal bug was detected. ...
    (borland.public.delphi.non-technical)
  • Re: Programming by Contract
    ... and having seen the sample of pycontract it seems it only does its thing during debugging. ... away the documentation ideas and unit testing ideas, and not worry about the rest. ... DbC is, roughly speaking, about explicit allocation of responsibility. ... Then it occurred to me to actually read the assert documentation, where I learned that one can pass a second expression to assert. ...
    (comp.lang.python)
  • Re: Programming by Contract
    ... I have seen posts about the assert statement and PbC, and I just took a very brief look at pycontract and now I have at least one question: Is this basically another way of thinking about unit testing, or is the idea of PbC more along the lines of *always* checking the input/output of functions to ensure they are correct? ... Well, from the complete lack of interest, I shall take away the documentation ideas and unit testing ideas, and not worry about the rest. ... DbC is, roughly speaking, about explicit allocation of responsibility. ...
    (comp.lang.python)
  • Re: from Dannys chat - 11/19
    ... >> Design by contract results in a nice clean syntax when it is built into ... >> the language, but it isn't anything you can not implement using asserts. ... > One of the benefits of DBC is that unit testing can be automated better. ... > automated tool that uses this information to generate test cases. ...
    (borland.public.delphi.non-technical)
  • Re: status of Programming by Contract (PEP 316)?
    ... and just live with the slowdown. ... Also, to repeat once again, the embedded self-test (DbC) checks can be ... do your unit testing, and wait for them to throw exceptions. ...
    (comp.lang.python)