Factory Introduction

Factory is a language that allows you to write and use generative templates for Java classes, so called factories. If you need classes for your programs which are similar but depend structurally on other classes, then you can create a factory template for them once and use that template whenever you need a particular variant. A factory has an arbitrary number of formal type parameters and resembles a normal Java class source, except that whenever a portion depends on parameters - be it a field, a method, a statement or part of it - a term in an XML-like syntax is inserted. Those factory terms are a very powerful and safe way to generate adapted code that depends on particular parameters.



The embedded Factory syntax integrates seamlessly with Java and Java's metamodel as specified in the reflection API. Reflection is based on the existing metamodel and Java objects can be created and accessed in a safely restricted way. Factory is an ongoing research project that tries to explore new criteria of type-safety for generative programming. Our work is aimed towards a particularly strong notion of type-safety which we call generator-type-safety that guarantees the correctness of all generated code independent of particular parameters. This is useful e.g. with regard to runtime reflection. Although our implementation uses only Java, the focus is not on any particular programming language but on generative programming and static source code analysis in general.



You can download Factory try out your own factories. Factory is open-source and freely available. Only remember that it is a research project in development that might still change.