Contracts vs debug

bearophile bearophileHUGS at lycos.com
Sat Feb 4 10:48:18 PST 2012


F i L:

> Why/where should I use contracts vs debug statements?

This is a sting point:
http://en.wikipedia.org/wiki/Design_by_contract

Contract-based programming is a different way to write programs. But adding few more asserts here and there is useful still.


>     int foo(int bar)
>     {
>         debug assert(bar != 0);

Asserts go away with -release. So generally I don't need to write that.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list