Good Contract programming idiom?

Lutger lutger.blijdestijn at gmail.com
Tue Mar 2 13:21:33 PST 2010


bearophile wrote:

>
> This can be done just keeping asserts in the precondition, and putting the
> exceptions in the body (if you are a really tidy person you can even
> disable the exceptions in not release built). But in practice I think the
> "good enough" thing to do is to be sure essential precontions are met, and
> stop the code otherwise.

The problem is this: in release mode you may be able to recover. The Date 
function may be part of a not so fundamental part of the application, or 
there is an alternative code path that can be tried. If you replace your 
asserts with exceptions that are then caught and recovered from, it becomes 
much harder to debug during development than is necessary. In this case you 
simply do not know, for these decisions are made probably on a higher level 
than a Date class.



More information about the Digitalmars-d mailing list