Mdsf: code generation vs MODEL INTERPRETATION

Source: Internet
Author: User
ArticleDirectory
    • Benefits of code generation over MODEL INTERPRETATION
    • Benefits of model interpretation over code generation
    • Method
    • Reference

InCode GenerationSpeaking of the model, you can use the Code Generation Technology and model interpretation methods to run in the domain framework. This article mainly introduces the advantages and disadvantages of the two methods.

Example
    • For the UI, we useModel-driven developmentAvailableCodeGenerate and run modelsProgram.
    1. Code Generation: The Form class is directly generated through the model. The generated form class is similar to the code written manually.
    2. Model Description: InOpenexpressappThe autoui in uses the model interpretation method. we predefine some form templates for the system. Each type of template corresponds to a form template class, and the specific form is read by the template to automatically generate the interface. A metawidget item automatically generated by the UI is just found. It uses the model explanation and has time to take a good look.
    • Design of entity classes:
    1. Code Generation: generate a specific class
    2. Model Description: The Interpreter generates an entity whose name is the object class name. In this entity example, multiple attributes are added. The attribute name is the object property name.
    Benefits of code generation over MODEL INTERPRETATION
      • Protect your intellectual property rights:InProduct Line Engineering ApplicationsTo generate code, you only need to generate the code for a specific user. When using model interpretation, you need to provide the complete interpretation engine and model to the customer.
      • Applicable to customer architecture:Model interpretation must implement an interpreter specific to your own architecture, and code generation can generate the Code required by the customer based on the customer's guidance.
      • The generated implementation code is easier to understand:You can directly view the generated code to understand the behavior of the application. To use model interpretation, you need to understand the general implementation of the interpreter and the semantic expression of the model.
      • Easy to start:If you have already used a traditional method to build an application, you can easily use the code generation technology to convert the current code into a template or replace part of the code. If you have built applications in multiple fields, you can analyze the differences between these systems and put common problems in the domain framework through static code, variable code is generated by code generation technology.
      • Easier iteration:The above code generation can use the code generation technology to generate existing code. We can easily generate a part of the code, and then expand to generate other code.
      • It is convenient to use the compiler for code check:The generated code can be checked by the compiler, while the model interpreter must write a model checker.
      • Debugging and code generation are easier than debugging interpreters:However, as a user, it is not necessary to debug the interpreter.
      • It is easier to track template changes:The code generation template is a text file, so some version control software can be used for tracking. Because of the versatility of the model interpretation code, its changes are more complex than the template change tracking.
    Benefits of model interpretation over code generation
      • Adapt to faster changes:Model changes do not require additional re-generation, building, testing, and deployment processes, which can significantly shorten the overall time.
      • Support runtime changes: You can change the application by changing the model at runtime without closing the application.
      • Easier deployment and operation:Code generation requires the compilation of the target application on the language platform. Instead, you only need to put the model into the model interpreter.It is easier for domain experts to deploy and run applications, rather than just modeling applications..
      • Easy to update: It is easy to change the interpreter and re-run the same model. You do not need to use the updated generator to generate code again.
      • More flexible than code generation:Templates generated based on Code have some restrictions, and the model interpreter can process them more flexibly.
      • Debug model during runtime:The model can be debugged at runtime. For example, you can set breakpoints in an activity like a system workflow, which is useful in complex processes and state models.
    Method

    From the above description, the conversion methods from the code generation and model interpretation models to the application have their own advantages and disadvantages, and there is no decisive argument to tell you which method to choose, this may be related to everyone's experience, preferences, and problem areas.

    If the business is complex, I want to have a corresponding class library in the application so that I can use OO to Write Business Code. Therefore, I personally prefer to use the Code Generation Technology for class library generation. Interface Generation is relatively universal, so you can use a common language to create some UI templates in the domain framework and automatically generate code through model interpretation.OpenexpressappThe current solution.

    If you also pay attention to MDD and understand code generation and model interpretation, what do you think?

    Reference

    Model Driven Development: code generation or model interpretation?

    Model interpretation vs. Code Generation? Both.

    Executable models vs code-generation vs MODEL INTERPRETATION

    Code Generation

     

    You are welcome to reprint it. Please note: Reprinted fromZhou jingen [http://zhoujg.cnblogs.com/]

    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.