Lightweight code generation scheme selection

Source: Internet
Author: User

The last time I talked about MyAppfuse, I had to have a code generation tool. codegeneration.net is a collection of tools for various platforms and languages.

Some of them use UML for metadata and become the most popular MDA tool of the previous year. In fact, the MDA is a hot potato. Even if the graduation thesis N years ago was about this topic, it is not much progress now.

However, it is normal to try again. Because MDA is composed of models, implementations, and conversion programs. If model definition develops rapidly, there will be a huge gap between them and the underlying implementation, and the conversion program needs to do a lot of work to eliminate them. When the gap is large enough, few will be willing to do this conversion. In order to reduce the gap, the first is to wait for the development of the underlying implementation, but this is a matter of the entire IT industry, not a personal problem of the MDA developers. In addition, many existing templates only rely on UML static Class diagrams and use a large number of Tagged values, it seems similar to a custom model in xml format.

Therefore, due to the constraints of the underlying implementation, the OMG structure is not like a very high-yield organization, and the emergence of MDA is not a great opportunity for everyone to wash their feet onto the field without Coding. However, with the development of bottom layers such as AOP, Meta-Data, O/R Mapping, and IOC Container, and the impact of Microsoft DSL on UML, MDA will continue to develop slowly, after all, this is our dream.

Currently, it is more practical to select some lightweight code generation solutions. I selected a custom model + jsp/Freemarker template in XML format. Of course, XDoclet can also be used like Appfuse, but I think the scalability, management and applicability of XDoclet are the lowest. You can also use the C #/Java program to completely control the generation of code without a template. This method now has more Python and Ruby dynamic languages to choose from.

However, I still prefer more templates. For example, jsp can use Httpclient to access jsp and obtain the returned content to generate a file. Metadata in xml format can be put into Request or Session through Filter.

However, Velocity and Freemarker are popular. The two can be determined in a three-game two-win system.

1. Freemarker has an article on its website listing the advantages of Freemarker syntax over Velocity.

Second, but the current PM cannot look at the problem from a purely technical perspective. Velocity has many more user groups than Freemarker, such as AndroMDA and IntelliJ IDEA.

Third, Freemarker is rarely mentioned about the metadata defined in XML format, but has no advantages-built-in xml dom access syntax. For example, the following metadata:

<Table>
<Column name = "id"/>
<Column name = "name"/>
</Table>

Freemarker can list the names of all columns in the table as follows:

<# List table. * as column>

$ {Column. @ name}

Compared with Velocity, JDom APIs are much simpler. In this case, Freemarker wins because too much xml Metadata is accessed during Code Generate. This also makes me ambiguous between jsp and freemarker. Originally, because the generated code is not a page, the advantage of freemarker markup-language is not. The advantage of jsp is that everyone understands it and has the best IDE, which is highly scalable and can do anything.

However, in the end, what to use as a template is not very important. Here we just write the group memoring process to record the low decision.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.