What if you baked your code?
'CodeBaking' is a design time, optimization process, code snippet engine, code reviewing, validation, code generation tool. It aids you by injecting real code into your existing code. The longer you leave it in the oven (based on settings), the more it can do (based on settings).
Create your code. Any code, you may but don't need to put directives for the baking process. Your real code mixed with special template constructs that request of the oven, certain things. SExpressions such as <% expression %> where expression is lambda, and/or oven instructions. For example Nullcheck(variables), will inject code for all variables to be check. Also, exclusions like NoLog, or Ignore or perhaps even range checking ValueRange(0-9), injects code to make sure the parameter is as required. Of course it could also look at real Attributes as well.
For a moment, forget about the actual syntax and semantics of the Expressions , but consider only one pseudo example.
[code:c#]
publicclass MyClass
{
publicint MyMethod(string p, <% ValueRange(0-9) %>int i)
{
<% LogException %>
string myP;
int myI;
int result = 0;
<% Validate(parameters) %>;
<% PushToFields(parameters) %>;
if (result >0)
{
<% LogValue(result) %>;
}
return result;
}
}
[/code]
Now, you push your code into an "oven". Put it in for 20 seconds (perhaps microwave would be better). It iterates through your code, and with each iteration positively affects the code.
something like this:
Using the Expressions, generates your requested code
Validates your code and inserts type checking, null checking
Adds Exception handling around blocks of code
Applies something else
Then you have a new code file based on your old one, but it always knows what was yours and what it inserted, therefore a simple click, would remove the generated code from your selected property or method. You now continue writing, amending code. the code gets more complete, more robust.
Why stop there.
The Oven, is also capable of looking at running processes and compiled code. After a session of usage, it learns what it should do. So you then bake the code again, so it can apply the learnt aspects. Now it injects more error handling on methods that failed, more logging, splits methods out so that there is a more fine grained error graph and so on.