1 / 40

Intercalate

Intercalate. Modeling with Templates. Alodar Systems, Inc. The Object Explosion. Domain Objects + Views = Representations. Gene. SQL. Target. O/R Mapping. Sequence. Molecule. Java. Order. HTML. Scientist. etc. The Intercalate Process. Modeling Production. Dictionary.

amber-ryan
Download Presentation

Intercalate

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intercalate Modeling with Templates Alodar Systems, Inc.

  2. The Object Explosion Domain Objects + Views = Representations Gene SQL Target O/R Mapping Sequence Molecule Java Order HTML Scientist etc.

  3. The Intercalate Process • Modeling • Production Dictionary Prototype Template Dictionary Result Template

  4. Intercalate Benefits • Structured representation of domain • Powerful expression semantics • Synchronization • Maintainability and reuse

  5. Structured Representation • Template$key$ • Dictionarykey = value; • Resultvalue

  6. Powerful Semantics • For Iterate over a list • If Test condition • Unless Test negated condition • Write Redirect output • Include Redirect input

  7. Synchronization • If a domain object changes, all its representations change with it. • If a template changes, all domain objects immediately incorporate the new functionality. • Inadvertent editing errors are eliminated • Object representations remain consistent

  8. Maintainability and Reuse • Corrections to domain objects or templates are automatically distributed throughout the system • New domain objects can be added and immediately function in all contexts • New templates can be added and all domain objects immediately work in the new context

  9. Building a Template • The initial template is an example of the desired output • Move values from template to dictionary, leaving keys behind as place holders • Add control keywords to iterate over lists and generate text conditionally • Add directives to redirect output and input.

  10. Identify occurrences of the table name • Prototypecreate table Person ( Name char(100), ID number);alter table Person add primary key (ID);

  11. Insert the table name in the model dictionary • Dictionarytable = Person;

  12. Replace the table name with its dictionary key • Templatecreate table $table$ ( Name char(100), ID number);alter table $table$ add primary key (ID);

  13. Identify attributes of the first column • Templatecreate table $table$ (Namechar(100), ID number);alter table $table$ add primary key (ID);

  14. Insert column attributes in the dictionary • Dictionarytable = Person;column = Name;type = char;size = 100;

  15. Replace column attributes with dictionary keys • Templatecreate table $table$ ($column$$type$($size$), ID number);alter table $table$ add primary key (ID);

  16. Identify attributes of the second column • Templatecreate table $table$ ($column$$type$($size$),IDnumber);alter table $table$ add primary key (ID);

  17. Make a list of columns in the dictionary • Dictionarytable = Person;columns = ( {column = Name; type = char; size = 100;}, {column = ID; type = number;});

  18. Iterate over the entries in the columns list • Templatecreate table $table$ ($for columns$$column$$type$($size$),$end$);alter table $table$ add primary key (ID);

  19. Not all columns can use the same template Shouldn’t have parentheses or comma • Resultscreate table Person ( Name char(100), ID number(),);alter table Person add primary key (ID);

  20. Test conditions to produce text only when needed • Templatecreate table $table$ ($for columns$$column$$type$$if size$($size$)$end$$unless _last$,$end$$end$);alter table $table$ add primary key (ID);

  21. What We’ve Learned • Move values to the dictionary • Insert keys in the template • Iterate over a list of entries $for key$ … $end$ • Test conditions$if key$ … $end$$unless key$ … $end$

  22. Identify special usage of one or more columns • Templatecreate table $table$ ($for columns$$column$$type$$if size$($size$)$end$$unless _last$,$end$$end$);alter table $table$ add primary key (ID); Primary key

  23. Indicate special usage in the dictionary • Dictionarytable = Person;columns = ( {column = Name; type = char; size = 100;}, {column = ID; type = number;primary_key = ;});

  24. Restrict iteration using the special key • Templatecreate table $table$ ( … );alter table $table$ add primary key ($for columns(select primary_key)$$column$$unless _last$, $end$$end$);

  25. Test a condition having nested keys • Templatecreate table $table$ ( … );$if columns.primary_key$alter table $table$ add primary key ($for columns(select primary_key)$$column$$unless _last$, $end$$end$);$end$

  26. What We’ve Learned (2) • Indicate special usage with a distinct key • Restrict iteration $for key(select subkey)$ … $end$ • Test nested conditions$if key1.key2$ … $end$

  27. A Java example • Prototypepublic class Person { private String Name; private Integer ID; public String getName() { return Name; } public Integer getID() { return ID; }}

  28. Build a Java template • Templatepublic class $table$ {$for columns$ private $javatype$$column$;$end$$for columns$ public $javatype$ get$column$() { return $column$; }$end$}

  29. Create a lookup table for the Java data type • Dictionaryjavatype = $sql2java.type$;sql2java = { char = String; number = Integer;};table = Person;columns = ( … );

  30. Override general defaultin special cases • Dictionaryjavatype = $sql2java.type$;…table = Person;columns = ( ... {column = ID; type = number; primary_key = ;javatype = BigInteger; });

  31. What We’ve Learned (3) • Use a dictionary with a new template • Use a lookup table for systematic translation of values • Override default values in special cases

  32. Make a list of tables in the dictionary • Dictionarytables = ( {table = Person; … }, {table = Vehicle; columns = ( {column = VIN; … }, {column = make; … }, {column = owner_id; … } ); });

  33. Create SQL for tables in the tables list • Template$for tables$create table $table$ ( … );$if columns.primary_key$alter table $table$ add primary key ( … );$end$$end$

  34. Create Java for tablesin the tables list • Template$for tables$public class $table$ {…}$end$

  35. Each Java class goes in its own file • Template$for tables$$write table.java$public class $table$ {…}$end$$write$

  36. Include other templates • Template$for tables$$write table.java$public class $table$ {…$include table.extras$}$end$$write$

  37. What We’ve Learned (4) • Nested iteration • Redirect output to one or more files$write key.ext$ • Restore output to standard out$write$ • Import other templates$include key.ext$

  38. The Intercalate Process • The initial template is an example of the desired output • Move values from template to dictionary, leaving keys behind as place holders • Add control keywords to iterate over lists and generate text conditionally • Add directives to redirect output and input.

  39. Intercalate Benefits • Structured representation of domain • Powerful expression semantics • Synchronization • Maintainability and reuse

  40. Additional Resources • Alodar Systems, Inc.19616 Redbeam AvenueTorrance, California 90503 • Voice: 310-370-4557 • Fax: 310-371-4103 • Email: info@alodar.com

More Related