Bolstering developers, Microsoft Research has developed Code Contracts, offering a language-agnostic way to express coding assumptions in .Net.
The technology was released on the Microsoft DevLabs site this week. Code Contracts provide the innovations of "design by contract" programming to .Net programming languages. Contracts take the form of pre-conditions, post-conditions, and object invariants, and they act as checked documentation of APIs. Also, contracts improve testing via runtime checking and enable static contract verification and documentation generation.
[ At the VSLive conference today, Microsoft showed off the new Visual Studio UI. ]
"Today’s release, Code Contracts for .Net, is a general design-by-contract mechanism that all .Net programmers can now take advantage of," said S. "Soma" Somasegar, senior vice president of the Microsoft developer division, in his blog on Monday. "Using it, programmers provide method preconditions and post-conditions that enrich existing APIs with information that is not expressible in the type systems of .Net languages. Additionally, contracts specify object invariants, which define what allowable states an instance of a class may be in (i.e. its internal consistency.) "
Contracts, Somasegar said, are used for runtime checking, static verification, and documentation generation. Additionally, contracts allow automatic documentation checking and improved testing. Code Contracts for .Net consists of three components: the static library methods used for expressing the contracts, a binary rewriter, and a static checker.
The binary rewriter modifies a program by injecting contracts, which are checked as part of a program execution. Rewritten programs improve testability, and each contract offers a pass/fail indication for test runs. The static checker decides if there have been any contract violations, checking for implicit contracts, such as null dereferences and array bounds, as well as checking for explicit contracts.
Code Contracts can be used within Visual Studio 2008 Team System.
The design-by-contract mechanism was pioneered by Eiffel, Somasegar said.
This whitepaper explains the terminology and concepts behind Data Replication technologies and establishes some sizing rules through worked examples. Learn the new paradigm in disaster tolerance—protect data anywhere.
Download now »Download a free 30day trial and experience how XenDesktop delivers a pristine, ondemand desktop experience to users on whatever device they choose, while cutting IT complexity and costs.
Download now »
The emergence of WLANs has created a new breed of security threats to enterprise networks.
Included in HP ProCurve WLAN solutions is security technology that alleviates threats from WLANs through:
* Monitoring wireless activity inside and out of the enterprise
* Classifying WLAN transmissions into harmful and harmless
* Preventing transmissions that pose a security threat to the enterprise network
* Locating participating devices for physical remediation

Sign up to receive InfoWorld Resource Alerts
