Jostraca: a Template Engine for Generative Programming - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Jostraca: a Template Engine for Generative Programming

Description:

The template is accessible to many more developers without GP skills. ... Jostraca is the templating component in a GP infrastructure. ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 16
Provided by: richard900
Category:

less

Transcript and Presenter's Notes

Title: Jostraca: a Template Engine for Generative Programming


1
Jostraca a Template Engine for Generative
Programming
  • Richard J. Rodger

Presentation for the ECOOP2002 Workshop on
Generative Programming
2
Aspects of Generative Programming
  • representation of the problem domain
  • implementation of the solution domain
  • Jostraca is an implementation tool.
  • Jostraca provides a convenient way to generate
    code, but it is not a modelling tool.

3
Status of Generative Programming
  • GP is not widely used.
  • Most Developers do not use GP as a design or
    implementation strategy.
  • GP requires skills that are not mainstream.
  • GP is not user-friendly.

4
Templates and Models
  • Mainstream developers DO use templates and
    abstract data models JSP and XML
  • So use JSP syntax as the template syntax, because
    it is familiar.
  • Use XML for domain representation and assume
    third party tools are sufficient

5
Templates and Generators
  • Templates are a user-friendly way to specify an
    implementation.
  • A templating component can be used by the code
    generator to emit source code.
  • This approach is language and domain model
    neutral.
  • Jostraca is positioned as a templating component.

6
A Jostraca Template
  • lt String fields new String "FirstName",
    "LastName" int i gt
  • public class Person
  • lt for( i 0 i lt fields.length i ) gt
  • private String mltfieldsigt ""
  • public String getltfieldsigt()
  • return m ltfieldsigt
  • public void setltfieldsigt(String
    pltfieldsigt)
  • mltfieldsigt pltfieldsigt
  • lt gt

7
JSP Style Templates and Usability
  • The syntax is familiar to mainstream developers.
  • The implementation is proven.
  • Integration is relatively easy.
  • Almost WYSIWYG.

8
GP as a Development Approach
  • Not just Wizards and Compilers.
  • Developers must be able to define the
    implementation and domain model.
  • A feedback driven cycle of modification to
    implementation and domain model must be possible.
  • Easy-to-use templates enable the implementation
    part of this process.

9
The Customization Problem
  • Many development tools fail because they are too
    restrictive.
  • Customization of generated code is ALWAYS needed
    in practice.
  • Text based JSP templates afford easy
    customization.

10
Customization with Fixed Templates
  • Third party or standard templates are not
    normally customizable by alteration.
  • JSP templates are text based. This makes it more
    difficult to customize standard templates.
  • Approaches are use OO inheritance, include
    optional code snippets.

11
Structured Templates
  • To solve the customization problem we can use
    structured templates.
  • Structured templates are templates that we can
    selectively compose from other (parts of)
    templates.
  • How to do this is an open question.

12
Template Script Usability
  • JSP syntax is familiar but it is not pretty.
  • The usability of JSP templates can be
    dramatically increased by defining easy-to-read
    replacements for template scripting elements.

13
A Pretty Template
  • public class Person
  • //-for-each-field-//
  • private String mField ""
  • public String getField()
  • return mField
  • public void setField( String pField )
  • mField pField
  • //-end-//

14
Programming By Example
  • Make the template as close as possible to normal
    source code.
  • The template is accessible to many more
    developers without GP skills.
  • This removes a layer of abstraction, allowing us
    to work on the specific rather than the general
    solution.

15
Conclusion
  • Jostraca is the templating component in a GP
    infrastructure.
  • Templates should be as user-friendly as possible.
    In the extreme, they should be indistinguishable
    from problem specific source code.
  • Templates should be composable so that they can
    be structured to scale. How to do this is an open
    question.
  • See www.jostraca.org for more information.
Write a Comment
User Comments (0)
About PowerShow.com