Why no contracts for release build?

Sean Kelly via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 3 14:43:39 PDT 2014


On Tuesday, 3 June 2014 at 14:29:19 UTC, Andre wrote:
> Hi,
> I currently think about whether or not contracts should be 
> available in release builds.
...
> I think Contracts are not a feature solely for unittests, they 
> are a fundamental part of classes/interfaces and theirfore 
> should be available in all builds.

I think the problem is that "release" is a misnomer, because the
presence of contracts has nothing to do with whether you're
deploying a test or release build.  For all the talk of how we
should be profiling our code to find the trouble spots instead of
prematurely optimizing, the release flag, by virtue of its name,
exists as a giant red button we're all expected to press for
"performance" or whatever before deploying our software for use
in the first instance where safety actually matters.

As for the idea that contracts simply aid in finding logic errors
during testing... for testing to have any validity the test must
be performed on the same build that will be released to the
public.  And the idea that testing will ever find all the
problems that might occur in the field is laughable.

In short, pretend "release" says something like "unchecked" and
think hard before actually setting it in real code.


More information about the Digitalmars-d mailing list