[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[stellation-res] Comparing abstractions
|
I did a bit of cleanup on Rodolpho's submission, and wrote a very
quick prototype of the template mechanism. They're checked in to the
latest version of core under repos/database. For comparative purposes, here's
a single table implemented in each:
Table table = new Table("Properties", _typeMap);
table.addField("aid", "INTEGER");
table.addField("vid", "INTEGER");
table.addField("inheritable", "INTEGER");
table.addField("name", "SHORTSTRING");
table.addField("value", "LONGSTRING");
table.addPrimaryKey(new String[] {"aid", "vid", "name"});
table.addForeignKey("fk3", "Versions",
new String[] { "aid", "vid" },
new String[] { "aid", "vid" });
System.out.println(table.generateSQL());
String orig = "CREATE TABLE Properties (\n" +
" aid ${INT}, \n" +
" vid ${INT}, \n" +
" name ${SHORTSTRING}, \n" +
" value ${LONGSTRING}, \n" +
" PRIMARY KEY(aid, vid, name), \n" +
" CONSTRAINT fk3 FOREIGN KEY (aid, vid) " +
" REFERENCESVersions(aid, vid))";
TemplateExpander te = new TemplateExpander(typeMap);
String result = te.expandTemplatesInString(orig);
System.out.println("Orig: " + orig);
System.out.println("Result: " + result);
In terms of implementation, the work to convert either one into
something we would actually use is pretty much equivalent, so
the decision should be based solely on what we consider the
better, clearer design.
I can see advantages to each, but I lean slightly towards the templates.
To me, it looks like we lose something by obscuring the SQL. The
object approach is more flexible, but it's also more obscure.
What are others preferences?
-Mark
--
Mark Craig Chu-Carroll, IBM T.J. Watson Research Center
*** The Stellation project: Advanced SCM for Collaboration
*** http://www.eclipse.org/stellation
*** Work Email: mcc@xxxxxxxxxxxxxx ------- Personal Email: markcc@xxxxxxxxxxx