Angel \”Java\” Lopez on Blog

July 7, 2010

Building an Application using AjGenesis (Part 1)

Filed under: AjGenesis, Code Generation, Open Source Projects — ajlopez @ 8:45 pm

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.

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

4 Comments »

  1. [...] Building An Application Using AjGenesis (Part 1) Armando una aplicación usando AjGenesis (Parte 1) [...]

    Pingback by Armando una aplicación usando AjGenesis (Parte 2) - Angel "Java" Lopez — July 10, 2010 @ 3:59 pm

  2. [...] Building An Application Using AjGenesis (Part 1) Armando una Aplicación usando AjGenesis (Parte 1) Building An Application Using AjGenesis (Part 2) Armando una Aplicación usando AjGenesis (Parte 2) [...]

    Pingback by Armando una aplicación usando AjGenesis (Parte 3) - Angel "Java" Lopez — July 12, 2010 @ 10:51 am

  3. [...] Building An Application Using AjGenesis (Part 1) Building An Application Using AjGenesis (Part 2) Building an Application Using AjGenesis (Part 3) [...]

    Pingback by Building an Application Using AjGenesis (Part 4) « Angel “Java” Lopez on Blog — July 14, 2010 @ 7:28 pm

  4. [...] Building An Application Using AjGenesis (Part 1) Armando una Aplicación usando AjGenesis (Parte 1) Building An Application Using AjGenesis (Part 2) Armando una Aplicación usando AjGenesis (Parte 2) Building an Application Using AjGenesis (Part 3) Armando una Aplicación usando AjGenesis (Parte 3) Building an Application Using AjGenesis (Part 4) Armando una Aplicación usando AjGenesis (Parte 4) Building an Application Using AjGenesis (Part 5) [...]

    Pingback by Armando una aplicación usando AjGenesis (Parte 5) - Angel "Java" Lopez — September 14, 2010 @ 8:57 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 68 other followers

%d bloggers like this: