What is Code generation defined?
„Code generation is the technique of using or writing programs
that write source code.“
Code generation in Model Driven Engineering, what is it?
Generation of text from models , whereas text may be distinguished, e.g., in
How can Generation of text from models with text be distingueshed?
Program code (source code)
Documentation
Test cases
Deployment scripts
etc.
Why should I use code generation?
Current execution platforms are mostly code based
Enables separation of (high level) system definition (model) and implementation (
Possible to change the target language without changing the model
Increase maintainability , extensibility, portability to new hardware, operating systems, and platforms
Name Code generation approaches
Code generation with model to model transformation languages
Code generation with programming languages
Code generation with model to text transformation languages
Code generation with M2M transformations
name andvantages:
Reusability: M2M transformation allows for the reuse of existing models, which can save time and effort in the development process.
Interoperability: M2M transformation can be used to convert a model into a format that can be used by other tools or systems, which can improve the interoperability of the system.
Quality assurance: M2M transformation can be used to check the consistency and completeness of a model, which can improve the quality of the system.
Abstraction: M2M transformation can be used to change a model from a high-level abstraction to a lower-level abstraction or vice versa. This can make it easier to understand and work with the model.
Automation: M2M transformation can be automated, which can make the process more efficient and less error-prone.
Model-Driven Development: M2M transformation can be used as part of a Model-Driven Development (MDD) process, which can improve the efficiency and quality of the software development process.
Well formedness of the generated target code can be easily ensured
Well formedness of the target model w.r.t. target language metamodel
can be statically checked
What is the basic idea of M2M Transformation?
Basic Idea : Transform source model into a target model that can be directly serialized as target language code
M2M (Model-to-Model) transformation -> process that takes a source model (which respresnts a system) -> converts it into a target model.
The target model can be used in a different way or in a different format than the source model.
One of the main goal of M2M is to be able to directly serialize the target model as code in a specific target language.
name disadvantages:
Metamodels for programming languages are very complex
Model transformations towards metamodels for programming languages are usually very complex
Metamodels for programming languages are not always available
Code generation with programming languages what is the Basic Idea:
Traverse model and produce target text (code) with
String operations
What is more efficient in lines of code per transformation?=
MiniUML to Java code generator realized with Java needed 120 lines of java code are neede to realize mapping
80% less code than with model to model transformation
Code generation with programming languages - what is the Code generation process? / Requirements?
Load models
Load XMI file into memory (de serialization)
Process models and produce code
Process models by traversing the model structure
Use model information to produce code
Save code into String variable
Write code
Persist String variable to a file using streams
Last changed2 years ago