Unofficial wish list status.(Jul 2008)

Bruce Adams tortoise_74 at yeah.who.co.uk
Thu Jul 24 16:03:57 PDT 2008


On Thu, 24 Jul 2008 11:30:35 +0100, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Sean Kelly and others:
>> For what is worth, I also like contracts :)
>
> I too like them. At the moment in D I expecially like class contracts  
> used as invariants. So I'd like to see the compiler manage contracts in  
> a smarter way.
>
> Bye,
> bearophile

I don't normally approve of me tooing. It wastes bandwidth. But on the off  
chance it
has any persuasive power at all. Me too.

I use them extensively at work where I'm forced to use C++. They are  
documented using
Doxygen and are used heavily to write the first set of unit tests. When  
fixing up legacy
code one of the first things I look for are the pre-conditions the  
post-conditions and
the invariants. These get documented. Then they get tested. This  
immediately picks up a lot
of otherwise subtle and evil bugs. And the whole code base moves forward.
They also help to expose when you have functions doing too much. If the  
post conditions
become ridiculously complicated then its a fair bet the code has two and  
would benefit from
some re-factoring. Maybe not a silver bullet but one of the more important  
tools in the arsenal.
The pairing of contracts and unit tests was one of the first things that  
interested me in D.
They deserve more attention. After all writing code is easy. Its writing  
clean correct code
that takes more effort.

Regards,

Bruce.



More information about the Digitalmars-d mailing list