Archive for January, 2008

Domain Specific Language Project

I’ve been very interested in what has been happening in the world of Domain Specific Languages and Software Factories for quite some time now. I’ve been using a common persistent object pattern (engine, collection, class variant) since 2001, albeit moving from C++ ATL to C#. I’ve been using a code generator to generate these objects since early .NET days.

The only problem with this scenario is optimum efficiency. Working this way, one models the domain object for the solution in a UML tool, then re-enters all that information into the custom code generator application which then produces C#, SQL, unit test and GUI code that is manually incorporated into Visual Studio. Much more efficient than hand-coding but still not optimal.

With the advent of Domain Specific Language Tools in Visual Studio 2005 SDK, Microsoft has provided a very good environment to design and implement DSLs and Software Factories. The modeling of the objects is done in Visual Studio (VS) and code is generated directly into the VS environment…a simple build and it’s ready to go.

I started looking at DSL tools in VS 2005. It’s pretty much the same in VS 2008. I won’t go into all the details, but this is one of the best modeling and template transformation tools I’ve come across (with albeit limited experience in this area).

Basically Microsoft provides an excellent DSL creation tool and very powerful solution for template transformations via a flexible and extensible mechanism:

  1. Engine – Controls text template transformation process
  2. Host – Provides the interface between the Engine and the user environment (can create custom hosts).
  3. Directive Processors – Classes which handle directives in templates and allow template processing to be extended to do anything in code (can create custom directive processors).

The general process to follow to create a software factory using DSL tools is:

– Define your DSL (model type and key elements)

– Create the text template(s) needed to generate the code

– Install the DSL package to Visual Studio and start generating code and tests

It sounds straight forward, and when doing a persistent object factory it should be straight forward as Microsoft kindly provides a number of DSL starter templates, one of which, the Class Diagrams template pretty much creates the whole class modeling DSL for you (in fact I’m having to remove DSL elements that I won’t need). In other cases I can imagine this will be difficult for typical business system developers/architects as it works by providing an abstraction that defines an abstraction, so its interesting to see that you use the DSL tools to model your domain modeling tool! One needs to take a step back to get your head around this, then it starts to make a lot of sense.

Next post we’ll get into actually implementing it.

 

 

 

Advertisements