Forward Engineer SQL/Code Gen Tool (under development)

A little project I am working on in my spare time (like I have any) is an application to speed up the process of developing an initial application/web system. UML is a good place to start, design all your classes and their interactions in this and you are practically away, although it probably will only create your initial properties and fields it won’t write an methods for you (unless you define them in your UML diagram but then system designers would be programmers – (actually they probably already are anyway)). If you use a product like Enterprise Architect (developed here in Oz) you can even forward engineer all of your classes and have the code pretty much ready to import into your development environment whatever it may be.

What I want to be able to do is forward engineer UML diagrams into C# and also create all the stored procedures and tables in SQL Server as well as methods for accessing the data. Freeing me up for the more interesting things that come after you develop the initial system from the diagrams.

I don’t want to spend months developing a comprehensive UML application so I have started simple. An ASCII based template system. Here is an example –

# the name of this project (will also be the namespace name)
project codegentest

# the name of the database you are connecting to
database SERVER=(local);UID=sa;PWD=;Initial Catalog=CODGENTEST;Connection Timeout=150

# the location to generate the output files
output c:\temp\myclasses

# the classes go below

class people
firstname string
lastname string
end class

class organisation
name string
peopleList people[]
end class

When passed through the CodeGen tool (under development) it will create all the CS files for the classes that includes methods for loading the data from the database into the class. It will also create a SQL script file that will create all of the tables/stored procedures necessary for creating the SQL Server database. All of the output is generated from XSLT files that are loaded by settings in the application configuration file, so the application is completely customisable – you can add/modify/delete the templates as necessary. Here is a screen shot of the application –

It is going to rock I reckon!!