design by contract versus doctest

John Roth newsgroups at jhrothjr.com
Mon Apr 5 17:38:52 EDT 2004


"aku" <aku at europe.com> wrote in message
news:4071a6d4$0$5064$4d4ebb8e at news.nl.uu.net...
> On 2004-04-05, Peter Hansen <peter at engcorp.com> wrote:
> >  aku wrote:
> >

>
> The "downside" with DBC I see is: when the caller *cannot*
> ensure a precondition, then the behavior in the called
> function becomes unpredictable.

If the caller cannot insure the precondition, then
they shouldn't be calling that particular function.
The function is not providing the needed service.
This is a design issue, of course. DBC is not a
license to shove all the dirty work onto the caller;
it's a way of clearly separating responsibilities in
a useful fashion.

John Roth





More information about the Python-list mailing list