3rd edition - 2005.6.22 update
Last time, myAppfuse had a code generation tool, and a variety of platforms for various platforms were collected on the CodeGeneration.net. In fact, the code generation is an old thing as the Bad Smell, which is repeated, but in this era, you fully explore the inheritance, entrusted, reflection, and even AOP, Coding still boring, still repeat, this time needs from one More abstract hierarchy to describe the system, then regenerate the code we love and hate, this is the production programming (GP).
High-order MDA applications Those who use OMG UML-making models, with MOF, OCL, etc., which expects to compare the high-order MDA applications that compare the system, I don't think so, have a wide range of promotion, everyone washing The opportunity to do not need Coding in the field is not big. As a result, the OMG structure is unlike a very high yield organization. Its current results are relatively high. Second, it is the constraint of the underlying technology. Because MDA is composed of three models, implementation, and conversion programs, if the model defines the rapid development, there must be a huge drop between the underlying implementation, and the conversion program needs to be a lot of work. When the drop is large enough, it will be very willing to do this conversion. In order to reduce the drop: one is the development of the underlying realization, this is the entire IT industry, not the personal problem of the MDA developer. II only reduce the height defined by the model, such as AndroMDA, many ready-made templates only depend on UML static Class. However, with the development of AOP, Meta-Data, O / R Mapping, IOC Container, and Microsoft DSL's impact on UML, MDA will continue to grow slowly, after all, this is our dream.
Light code generation scenarios still quiessecate some lightweight code generation schemes. I picked the custom model of XML format Groovy Template formula template language (note that Groovy Template, is not groovy). 1.xml model Now omg is also loose mouth, UML is not a unique solution, can be described and converted through a higher layer model. The XML is undoubtedly the most powerful in light modeling. In Martin Fowler, it also believes that the UML does not look like a higher level of advanced language, and the flat XML may be more practical) 2. The generation plan can of course use xdoclet like Appfuse, but I think the XDoclet scalability, management and Applicable ranges are the lowest. You can also use the template to completely control the generation of the code with the C # / Java program, this way now is more Python, Ruby, Groovy these dynamic languages. But I am a custom template.
Module selection now has JSP, Velocity / FreeMarker and the latest Groovy Template. This time the selected battlefield moves from the web performance layer to the template generated by the lightweight code, the standard has changed. First, re-require the flexibility and scalability of the template code. Because the lightweight code generation does not engage in MVC, it is not necessarily a good MVC, so the template code itself can handle more complex logic. So JSP and Groovy Template This Script type is superior.
The second is to require built-in XML DOM syntax. Because our metadata is defined in XML, you want to access too many XMLs in the process of Code Generatate, the simple and intuitive syntax is very useful, whether the template readability is still a writing speed, such as the following metadata: < Table>
<#list table. * as column> $ {colorn. @ name} # list>
JSP and Velocity use long JDOM syntax to make templates very dirty.
The third is because the generation is code, not a page, not a beautiful engine, the advantage of FreeMarker / Velocity Markup-LanguAg does not exist.
Four, there is a simple code, JSP is the least simple, and Groovy is more charming as a new generation of dynamic languages.
5 is IDE, FreeMarker, Velocity, Groovy Template A comparable to a cold acid
It can be seen that JSP is stronger than Velocity / FreeMarker handles logic, and the Java language will be; and Velocity / FreeMarker is simpler than JSP, and does not need to rely on Web Container, FreeMarker's built-in XML syntax. Groovy Template is precisely the combination of the advantages. Of course, it is currently not yet mature, and there is no good ide. SO, team Groovy Template or FreeMarker is a feasible choice. Speaking of the end, what to do, it is not a very important thing, it is not difficult to migrate in the template, just write the Group Memoring, record the process of low decisions.
Related article: Generate code 2nd with Groovy Template