This is the first step in a tutorial about how to use AjGenesis to generate an application. The target solution will be .NET, with C#, but I will add some VB.NET, PHP and Java examples, as a “proof of concept” of the power of an abstract model.
This is the first step: write a simple model. You can write the model in XML files, or in plain text files. In this first step, I will write the model in XML format.
The initial model is a free one: you can design the model as you want. In this serie of post, I will refine the model, step by step, to show how to design a complete solution, that can be reused and extended with manual code and extensions. I want to model an enterprise application: customers, suppliers, invoices, payments, etc. Let start with Customer and Supplier.
(You can download the code from AppExampleStep01.zip (only three short XML files))
This is the Customer.xml file:
<Entity> <Name>Customer</Name> <Properties> <Property> <Name>Name</Name> <Type>Text</Type> </Property> <Property> <Name>Address</Name> <Type>Text</Type> </Property> </Properties> </Entity>
There is a similar file for Supplier.xml. Note that there is no schema to follow: you can add any tag in a well formed document. In the next steps, I will load the model in memory, to be process by AjGenesis tasks and template. AjGenesis will recognize automatically that <Properties> is a list of tags <Property>. See that there is simple values, like <Name>, and compound ones, like <Property>.
One of the principles that guided me in my design choices was: the model (XML, text file, etc..) should not hurt my eyes. So, instead of write all the model in only one file, I wrote another XML file that include the entities:<Project> <Name>AjApp</Name> <Description>Building an Application using AjGenesis</Description> <Model> <Entities> <Entity Source="Customer.xml"/> <Entity Source="Supplier.xml"/> </Entities> </Model> </Project>
The attribute Source is a distinguished one: AjGenesis process that tag including the content of the referenced file, as it were in the parent file. When AjGenesis load the model, it will be one in memory, altought it is serialized in many files.
Next steps: how to use this model in AjGenesis, and generate some C# files from it.
Angel “Java” Lopez