Archive for February, 2007

DAL sweet DAL

Sunday, February 4th, 2007

For now … it seems that Active Record it’s the way to go. This allows me to concentrate all the queries to the database in just one point without keeping table or view references in the code. Also at this level I can implement a caching system if needed. I already generated a set of classes for each table using FuelGenerator.

Basically using this pattern I only work with one record at the time, the current record is represented as an instance of class that holds a description of the table or view entity. There is another layer which makes all the calls to the database. I’m still working on this class to solve all the glitches.

Code generation

Saturday, February 3rd, 2007

Three weeks ago I finally started working on the Fuel CMS project after an intense (?!) 7 month laziness. So evidently I started by building my code generator application.

FuelGenerator is built in Perl and at the moment connects only to MySql databases to retrieve information for the current database such as table information (columns and indexes), the information is stored in custom data classes that later on are serialized (JSON) and sent to the template file.

FuelGenerator is a pluggable template system and uses the PHP5 CLI or the erb (Ruby) interpreter. Basically the serialized information is sent to a file called “include file”. The “include file” will deserialize the JSON structure and
include the actual template file in which we have references to the deserialized structure.

Example:

1
2
3
4
$table = json_decode('{TABLE}');	
$parameters = json_decode('{PARAMETERS}');
 
{CONTENT}

{TABLE} represents the definition for the current table and is identified with the JSON info structure for it.
{PARAMETERS} is the JSON structure for the additional template parameters.
{CONTENT} is the content for the template.
All these values are replaced at runtime and then excuted with the specified interpreter, after the execution the generated content is saved into a a file.

I will place a copy of this application for download as soon as I finish the POD (Plain Old Documentation) for the Perl files.

CamelBones

Saturday, February 3rd, 2007

Yesterday I discovered CamelBones, a really nice “Objective-C/Perl bridge framework” which llows you to develop Cocoa applications using Perl a primary language. So far I started reading the tutorials and building the sample application and it’s very easy to use. I’m gonna experiment with this technology and try to move the current FuelGenerator application to have a graphic interface using CamelBones.

camelbones.png