The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Code Generation and Source Code Baking

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jonathan Crossland

Posts: 630
Nickname: jonathanc
Registered: Feb, 2004

Jonathan Crossland is a software architect for Lucid Ocean Ltd
Code Generation and Source Code Baking Posted: Jan 28, 2009 5:16 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Jonathan Crossland.
Original Post: Code Generation and Source Code Baking
Feed Title: Jonathan Crossland Weblog
Feed URL: http://www.jonathancrossland.com/syndication.axd
Feed Description: Design, Frameworks, Patterns and Idioms
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Jonathan Crossland
Latest Posts From Jonathan Crossland Weblog

Advertisement
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#]
    public class MyClass
    {
        
        public int 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.

Codebaking coming soon ?

Read: Code Generation and Source Code Baking

Topic: CodeGen on the Web Previous Topic   Next Topic Topic: How to Boost Website traffic and Twitter Followers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use