What I didn't tell you at the time, is that I was also working on a code generation tool which would allow me to generate a database-driven web application, just like this, in minutes.
The first version, called auto_coder, took an SQL script and generated all the required Perl scripts, modules and templates. The problem was that SQL isn't extensible: there's only so much information you can infer from a SQL script.
The solution was to use an extensible markup language -- XML for short :) -- to describe the database and all the required information.
This lead to a new version of my code generator, which I called "AppML" ("Application Markup Language").
Here's a small application described in AppML:
<project name="sample" title="Sample Application"> <table name="contact" caption="contact" descriptor="name"> <field name="name" type="varchar" size="40" notnull="1" caption="n +ame"/> <field name="organization" type="varchar" size="40" caption="organ +ization" visible="1"/> <field name="phone" type="varchar" size="40" caption="work phone"/ +> <field name="fax" type="varchar" size="40" caption="fax"/> <field name="mobile" type="varchar" size="40" caption="mobile"/> <field name="email" type="varchar" size="40" caption="e-mail" visi +ble="1"/> <field name="notes" type="text" caption="notes"/> </table> </project>
That's it!
Given the XML file, a Perl script will generate the complete Perl code, Class::DBI modules, templates (using Template Toolkit), documentation and diagrams automatically.
Of course, you can include as much details as needed. For instance, a project can have multiple tables and relationships:
<project name="crm" title="CRM"> <table name="sector" caption="sector" descriptor="description"> <field name="description" type="varchar" size="40" notnull="1" cap +tion="sector"/> <field name="comments" type="text" caption="comments"/> </table> <table name="comp_size" caption="company size" descriptor="descripti +on"> <field name="description" type="varchar" size="40" notnull="1" cap +tion="size"/> <field name="comments" type="text" caption="comments"/> </table> <table name="occupation" caption="occupation" descriptor="descriptio +n"> <field name="description" type="varchar" size="40" notnull="1" cap +tion="occupation"/> <field name="comments" type="text" caption="comments"/> </table> <table name="contact" caption="contacts" descriptor="display_name"> <rel name="sector" type="association" table="sector" caption="sect +or"/> <rel name="comp_size" type="association" table="comp_size" caption +="comp_size"/> <rel name="occupation" type="association" table="occupation" capti +on="occupation"/> <field name="first_name" type="varchar" size="40" notnull="1" capt +ion="first name" visible="1"/> <field name="last_name" type="varchar" size="40" notnull="1" capti +on="last name" visible="1"/> <field name="display_name" type="varchar" size="40" notnull="1" ca +ption="display name"/> <field name="organization" type="varchar" size="40" caption="organ +ization"/> <field name="address" type="varchar" size="40" caption="address"/> <field name="city" type="varchar" size="40" caption="city"/> <field name="state" type="varchar" size="40" caption="state"/> <field name="country" type="varchar" size="40" caption="country"/> <field name="phone" type="varchar" size="40" caption="work phone"/ +> <field name="fax" type="varchar" size="40" caption="fax"/> <field name="mobile" type="varchar" size="40" caption="mobile"/> <field name="email" type="varchar" size="40" caption="e-mail"/> <field name="notes" type="text" caption="notes"/> </table> </project>
I'm releasing AppML under the GNU General Public License, and the complete source code is available for download.
Any feedback will be appreciated!
Best wishes,
Nelson
--
Nelson Ferraz
GNU BIS
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Code Generation in Perl
by chromatic (Archbishop) on Jun 16, 2004 at 22:51 UTC | |
by nferraz (Monk) on Jun 17, 2004 at 17:16 UTC | |
|
Re: Code Generation in Perl
by Zaxo (Archbishop) on Jun 16, 2004 at 21:01 UTC | |
by nferraz (Monk) on Jun 17, 2004 at 17:43 UTC | |
|
Re: Code Generation in Perl
by perlfan (Parson) on Jun 17, 2004 at 00:40 UTC | |
by nferraz (Monk) on Jun 17, 2004 at 19:23 UTC | |
|
Re: Code Generation in Perl
by autarch (Hermit) on Jun 18, 2004 at 03:19 UTC | |
by nferraz (Monk) on Jun 18, 2004 at 13:19 UTC | |
|
Re: Code Generation in Perl
by Jenda (Abbot) on Jun 19, 2004 at 10:23 UTC | |
by nferraz (Monk) on Jun 19, 2004 at 13:19 UTC |