BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage Presentations Compile-time Verification, It's Not Just for Type Safety Any More

Compile-time Verification, It's Not Just for Type Safety Any More

Bookmarks
01:01:30

Summary

Greg Young talks about .NET’s Contracts library, showing how to use it, what it is good for, and how it improves code quality.

Bio

Greg Young is co-founder and CTO of IMIS, a stock market analytics firm. He has 10+ years of varied experience in computer science from embedded operating systems to business systems. In his spare time you can often find Greg on experts-exchange.com where he runs the .NET section of the site, writing articles for InfoQ.com, or speaking at local .NET groups.

About the conference

QCon is a conference that is organized by the community, for the community.The result is a high quality conference experience where a tremendous amount of attention and investment has gone into having the best content on the most important topics presented by the leaders in our community.QCon is designed with the technical depth and enterprise focus of interest to technical team leads, architects, and project managers.

Recorded at:

Jul 05, 2011

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Slides are not available for downloads

    by komal gohil,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Please provide a link to download presentation.

  • Do you use Edit-Continue in Visual Studio?

    by Dzmitry Lahoda,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    www.rationalsurvey.com/s/1059

    11.7 Edit-Continue Not Working
    When using runtime checking of contracts, the IL is rewritten by our tools. Edit-continue relies on being
    able to insert code into an existing executable. Since that feature is not aware of the contract rewriting, it
    won't work. There's no work-around other than not using edit-continue when also using contracts.

  • Re: Slides are not available for downloads

    by razvan baciu,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hi Komal,

    There were no slides for this presentation. It was a live demo and discussion.
    Thanks!

    Razvan

  • requirement for VS 2010 premium, ultimate, or academic for static checking

    by John Wigger,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Greg certainly points this out but keep in mind that Visual Studio 2010 Professional (or lesser) can't use static checking. This is an exciting talk and will definitely motivate people to try this out. However, users with Professional can't take advantage of static checking. Hopefully Visual Studio 2012 or 2013 will resolve this ...
    - John Wigger

  • Is it supposed to work with VB.NET

    by Louis Routhier,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I tried using Microsoft.VisualStudio.Tools.Applications.Contract.v10.0 in a VB.NET WPF project but I can't get the compiler to throw me compilation errors. Is there anything special we need to activate when using VB.NET? Or is it another library I should use?

  • Re: Is it supposed to work with VB.NET

    by Louis Routhier,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Sorry, it is System.Diagnostics.Contract... No reference added... But still, it doesn't seem to work with VB. (I'm using VS premium)

  • Re: Do you use Edit-Continue in Visual Studio?

    by Dzmitry Lahoda,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    It appears that 30% of questioned of 50 total(40 in survey and 10 in our team) uses Edit and Continue.
    So using contracts prevents them from doing it.

  • Re: Is it supposed to work with VB.NET

    by Jonathan Allen,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Last time I checked it worked with VB, but badly. They didn't properly handle concepts like (If X = "" Then) meaning the same thing as (If string.IsNullOrEmpty(x)). That was over a year ago and they may have fixed it since.

  • The right idea, but the wrong design

    by Jonathan Allen,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Code contracts should be expressed declaratively as much as possible. It shouldn't require three lines of code just to say parameters x, y, and z cannot be null. Instead we should have attributes for all of the common cases.

    The second problem is the utter lack of support for reflection. There is no way to programatically determine what contracts apply to the public API on a class.

    The third problem is that it is an all or nothing proposition. Because contract violations crash the application you cannot safely mix contract and non-contract code in the same program. Had they choosen to use standard concepts such as ArgumentException and InvalidOperationException this wouldn't be a problem.

    In short, the design of this is just plain wrong. They need to go back to square one and rethink how contracts should be expressed and enforced.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT