back-2-basics: code contracts
DESCRIPTION
Overview on how to use .NET Code Contracts for a better why to do parameter/ value checking.TRANSCRIPT
![Page 2: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/2.jpg)
About David McCarter
$12
Specia
l
•Microsoft MVP•David McCarter’s .NET Coding Standards• dotnetcodingstandards.notlong.co
m•dotNetTips.com• 700+ Tips, Tricks, Articles, Links!
•Open Source Projects:• http://codeplex.com/dotNetTips
•San Diego .NET Developers Group• www.sddotnetdg.org
•UCSD Classes• http://
dotnetdaveclasses.notlong.com
![Page 3: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/3.jpg)
dotNetDave Conference DVD! Packed full of:
Videos of all sessions from 2010 & 2011(1)!
Slide decks from 2011 & 2010!
Demo projects from 2011 & 2010!
David McCarter’s .NET interview Questions!
Extras Conference Photos
from 2010! Surprise videos!
Only
$15!
Book + DVD $25!
![Page 4: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/4.jpg)
Agenda
Overview Demo’s!
Summary
5
![Page 5: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/5.jpg)
Overview
![Page 6: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/6.jpg)
Introduction to Code Contracts New API + tools from Microsoft System.Diagnostics.Contracts MSIL rewriting Inspired by Spec# Included in .NET 4.0 but…
Download available now for .NET 3.5 and VS2008
http://research.microsoft.com/en-us/projects/contracts/
![Page 7: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/7.jpg)
Design by Contract
A discipline of analysis, design, implementation, management
Applications throughout the software lifecycle: Getting the software right: analysis, design ,
implementation Debugging & testing Automatic documentation Getting inheritance right Getting exception handling right Maintenance Management
![Page 8: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/8.jpg)
Design by Contract
Every software element is intended to satisfy a certain goal, or contract For the benefit of other software
elements (and ultimately of human users)
The contract of any software element should be Explicit Part of the software element itself
![Page 9: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/9.jpg)
The three questions
What does it expect?
What does it promise?
What does it maintain?
Precondition
Postcondition
Classinvariant
![Page 10: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/10.jpg)
Real World Contracts!
Demo’s
![Page 11: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/11.jpg)
Summary
![Page 12: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/12.jpg)
Resources
Microsoft Research http://research.microsoft.com/en-us/
projects/contracts/ Channel 9
http://channel9.msdn.com/Search/?Term=code%20contracts
![Page 13: Back-2-Basics: Code Contracts](https://reader033.vdocuments.net/reader033/viewer/2022052619/5562d9d2d8b42a49398b5358/html5/thumbnails/13.jpg)
Questions?•Presentation Downloads• slideshare.com/dotnetdave
•Please Rate My Session:• speakerrate.com/
dotnetdave•David McCarter’s .NET Coding Standards• dotnetcodingstandards.notlong.co
m•Geek Swag• geekstuff.notlong.com