Code Contracts in .NET Help Distributed Software Development Teams
The notion of design-by-contract programming has been around for quite a while
Microsoft’s Research in Software Engineering (RiSE) team is on to something. Luckily, for developers around the world, they have released it to the public. I’m talking about Code Contracts in Microsoft .NET. Code Contracts are very useful under any circumstance; however, they are particularly useful in helping distributed software development teams increase team efficiency, improve product quality, and mitigate against risks associated with team dispersion.
The notion of design-by-contract programming has been around for quite a while. In fact, Bertrand Meyer (founder of Eiffel) was writing about the trade marked Design by Contract approach as early as 1992. Design-by-contract programming, according to Meyer, is a fundamental but often overlooked tenant of object oriented programming. The addition of design-by-contract programming into the .NET framework provides a mechanism by which all .NET languages can benefit from increased reliability.
Distributed software development teams will find Code Contracts particularly useful. Distributed teams deal with the same issues as non-distributed teams. In addition; however, the distributed team must manage through issues related to communication, location, and sometimes culture. Development assignments, in the distributed team scenario, are often partitioned along horizontal or vertical boundaries. Parallel implementation typically requires up-front design and agreement upon the application interfaces. This allows the team members, or sub-teams, to code independently of one another. This approach requires a fair amount of blind trust that the various parts of the application will function as designed. Code Contracts eliminate the need for blind trust.
Consumers of internal and external APIs that include Code Contracts will know that all of the contract-defined pre- and post-conditions have been met. This will not only engender trust in current development efforts, it will support the promotion of code/object/service re-use during future development efforts.
Additionally, code contracts:
- Make the product stabilization process more efficient by weeding out potential run-time errors at compile time. In a distributed team, this reduces the probability that one group wastes time unknowingly debugging errors introduced by a remote group. Additionally, it helps reduce the vicious cycle of compile-deploy-test-debug-compile-deploy-test; which can be very time consuming and, thus, expensive.
- Enhance the continuous integration process by leveraging contracts to generate more meaningful unit tests. Improved testing and the guarantee that preconditions and postconditions have been met combine to produce more robust, higher quality software.
- Empower the software architects with additional tools that allow them to programmatically constrain developers. This is quite useful when managing offshore teams. In this scenario, the design-by-contract approach can help reduce documentation-derived management overhead and increase quality and reliability at the same time.
The announcement of .NET Code Contracts was a pleasant surprise, as it represents a maturity milestone for the Microsoft .NET platform. I look forward to adopting it because it gives my software architects another tool that can be leveraged to enforce the architectural fidelity of our products.
Code Contracts can be downloaded for use with Visual Studio 2008 Team System. The Code Contracts library will be included as a native namespace in the .NET Frameworks 4.0 release. Mike Barnett provides a great Code Contract tutorial on channel9.msdn.com.
Originally published at walterpinson.sys-con.com on June 11, 2009.
By Walter Pinson on October 8, 2018.
Exported from Medium on May 25, 2026.
Also published on:Medium
Intent Engineering — the newsletter
Notes on Intent Engineering and The Codified Practitioner. Weekend-paced. No spam, no hype.