InfoQ

InfoQ

Presentation

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Recorded at:
Recorded at

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

Presented by Greg Young on Jul 05, 2011 Length 01:01:30     Download: MP3
Sections
Architecture & Design,
Development
Topics
Code Quality ,
QCon London 2011 ,
Quality ,
.NET ,
QCon ,
Software Craftsmanship ,
Programming ,
Agile ,
Conferences ,
Code Contracts
The next QCon is in New York June 18-22, Join us!
 

How would you like to view the presentation?

In case you are having issues watching this video, please follow these simple steps to help us investigate the issue:
1. Right click on the video player and select Copy log
2. Paste the copied information in an email to video-issue@infoq.com (clicking this link will fill in the default details in most email clients).
Note: in case your email client hasn't automatically picked up the email subject, please include in your email the URL of the video too.
3. Done.
We will investigate the issue and get back to you as soon as possible. Thanks for helping us improve our site!
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.
  • This article is part of a featured topic series on Agile and also QCon
Slides are not available for downloads by komal gohil Posted
Re: Slides are not available for downloads by razvan baciu Posted
Do you use Edit-Continue in Visual Studio? by Dzmitry Lahoda Posted
Re: Do you use Edit-Continue in Visual Studio? by Dzmitry Lahoda Posted
requirement for VS 2010 premium, ultimate, or academic for static checking by John Wigger Posted
Is it supposed to work with VB.NET by Louis Routhier Posted
Re: Is it supposed to work with VB.NET by Louis Routhier Posted
Re: Is it supposed to work with VB.NET by Jonathan Allen Posted
The right idea, but the wrong design by Jonathan Allen Posted
  1. Back to top

    Slides are not available for downloads

    by komal gohil

    Please provide a link to download presentation.

  2. Back to top

    Do you use Edit-Continue in Visual Studio?

    by Dzmitry Lahoda

    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.

  3. Back to top

    Re: Slides are not available for downloads

    by razvan baciu

    Hi Komal,

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

    Razvan

  4. Back to top

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

    by John Wigger

    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

  5. Back to top

    Is it supposed to work with VB.NET

    by Louis Routhier

    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?

  6. Back to top

    Re: Is it supposed to work with VB.NET

    by Louis Routhier

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

  7. Back to top

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

    by Dzmitry Lahoda

    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.

  8. Back to top

    Re: Is it supposed to work with VB.NET

    by Jonathan Allen

    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.

  9. Back to top

    The right idea, but the wrong design

    by Jonathan Allen

    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.