Dr. Dobbs Got The Lowdown on Ada 2012 Contracts

In an article aptly named Ada 2012: Ada With Contracts we get a very nice presentation of the new Ada 2012 facilities for contract-based programming.

The most recent version of the Ada standard, known as Ada 2012, brings contract-based programming to a mainstream language. Preconditions, postconditions, type invariants, and subtype predicates allow software developers to specify their programs’ intent more clearly, in effect embedding requirements into the source code. This feature makes it easier to review and understand the program, and it facilitates verification by the compiler, static analysis tools, and/or runtime checks.

I’ve used these new-fangled shinys a bit, and they are nice. Very nice actually. There’s just something truly awesome about being able to add pre/post-conditions to your method specification. The extra level of information and protection against errors is pretty amazing, and it is so darn easy to work with.

If you haven’t already tried your hand at these new features, be sure to do so. As the article says at the very end:

…the techniques of contract-based programming represent a significant advance.

I wholeheartedly agree.

Leave a Reply