Friday, July 27, 2007

Simple Expression + Metadata = Code Generation

This is the idea behind the development tools I'm currently working on. The goal is to express a system implementation in the simplest possible terms using a procedural language (C#). To get an idea of what I mean by "simplest possible terms", see the code in the bowling example from RuleLink. Reading the signatures and metadata from the business logic classes, code would be generated to create a functioning application. Easier said than done.

Now that RuleLink is in a workable state, my next target is a framework for generating application code from the business logic classes. Say that you have implemented a method

NewAccount(string email, string password, bool joinMailingList)
Exposing this method to the framework, you should get a basic generated user form for entering these values. When the form is submitted, the method is invoked. The form could be generated for ASP.NET, MonoRail, or anything for that matter -- as long as the developer can step into the generated code and understand what is actually going on.

This basic form would be sufficient for prototyping an application, but in order to get on to a bona fide solution, we need validation, page flow, layout, styling, etc. These would be implemented using techniques that do not corrupt the clarity of the business logic and do not require coding additional layers that need to be tested and maintained. Validation, for example, might be expressed as:
NewAccount([Constrain(AccountRegistry.AddressExists)] string email, string password, bool joinMailingList)
To change or extend the basic application generation, you would use metadata, configuration, or use-specific components to plug into the generation framework. When actual business logic needs to be applied, you refer back to the business classes (as when we used AccountRegistry.AddressExists above).

Gazintas.RuleLink published

The newly-created Gazintas project promises '.NET tools to enable lightweight and expressive code' and the first component, RuleLink, provides a 'runtime code generator for wiring together side-effect-free functions'.

Tuesday, April 24, 2007

Light bulbs are for illumination

The best time, sometimes the only time, to capture your ideas is at conception. And the best way to make sure you've captured a cohesive and sensible idea is to describe it to someone else. Enter the blog: you can capture your ideas and receive helpful comments from people probably more intelligent than you. You gain the opportunity to find fame, fortune and, most importantly—connections. Isn't that worth fifteen minutes of your time?