Flexible but costly contracts, Development Plan

Coordinator
Aug 27, 2010 at 6:44 AM

Currently, Development is focused on creating contracts that apply only to class members, There are great features in my mind:

  1. Contracts can be applied using XML markup which is stored somewhere in the project.
  2. Contracts can be applied to interfaces and somehow imported by the implementing class
  3. Contracts can be dynamically compiled in run-time using custom expressions.

 

Any suggestions are welcome ;)

Coordinator
Aug 29, 2010 at 12:10 PM

Dear Navid

Here is a short summary of the the project. I hope you like it.

Name: Arcana.Contract
Platform: .NET Framework 2.0
Language: C#
Tools: PostSharp Community Edition + Team Foundation Server + VS 2010
Hosted: www.codeplex.com
License: GNU
Description:
Focus to create a Design-By-Contract framework in .NET, a design-by-contract framework, is one that, allows contracts(pre-condition, post-condition) to be stated decoratively outside the method implementation, Using attributes and [ optional XML markup ]. This allows for better maintenance, code-reduction(specially when working with properties), and re-usability of certain business operations. This way of programming is a direct outcome of AOP(Aspect Oriented Programming) in which "aspects" are applied decoratively to software components that further describe their run-time behavior which is in contrast with attribute-based programming in which static informational meta-data are simply applied on methods and properties. Following example shows this idea:

Example:

[Argument.Is.Not.Null("myObject")]
public void MyFunction(object myObject)
{
}

In this example, whenever MyFunction is called, The contract is evaluated in run-time for correctness. If condition failed, a proper exception is thrown.

What are the benefits ?

1) We can state contracts on interface level, Automatically all implementing classes will inherit the conditions.
2) We can centralize contracts about business operations in the business layer to a centralized location, using an scripting syntax or XML markup.
3) We can re-use complex business contracts and refer them from anywhere.
4) Contracts that are applied through an attribute contract, also appear in the documentation.
5) In method implementation we can only care about the actual business operation and forget about all conditions that could occur.
6) Business contracts can be tested separately and re-used by various components.

Overseen project outcome:
+ Dynamic Run-Time Compilation
+ Re-usability by stating contracts at interface-level so that implementations can inherit
+ Allow for integration of custom contracts
+ Allow usage of XML markup stored in project to centralize business operation contracts.
+ Full set of easy-to-use, efficient contracts alongside more complex contracts.
+ Separate Extensions for .NET 3.5, .NET 4.0 and ASP.NET MVC 2.0/ADO.NET Entity Framework 4.0