Automatic programming

The Generative programming is a special programming paradigm in the methodical software development. Characteristic of the generative programming is the automatic generation of program code by a generator.

  • 2.1 UML
  • 2.2 XML and XSLT
  • 2.3 Form Generators
  • 2.4 compiler - compiler
  • 2.5 Product Configuration
  • 2.6 Rapid Control Prototyping

Operation of a program generator

A program generator can best be understood as a normal program for the EVA principle. Due to certain input parameters of the program generator produces a given output, the so-called generat. However, the output of a generative program is again a program code, namely the code that should be executed for the more concrete situation.

Basis for automatically generated code is the abstraction of common programming constructs in formal models. Programming is divided into three phases:

A program generator and code generator is therefore dedicated to a generic application and program class. It refers to a specific, underlying generic program model, from which it generates the target code after konkretisierender parameterization. This may be a source code, intermediate code or binary code.

While a normal, functional programmed program covers the variance of tasks exclusively with data variables that generative programming is also working with variabilisiertem program code that is clearly pronounced only in relation to the target code.

This approach is particularly suitable for solving problems that occur in a correspondingly large number of variations in practice, since no small effort must be planned for the creation of the model and the generator. This effort can pay for itself due to higher code quality and shorter development time. Often the target programs are only temporarily generated for single use only and will be deleted afterwards. As a result, at any given time the persistent existing program code, such as measured by the number of lines of code may be, if necessary, reduced by a few orders of magnitude.

Generative programming is recommended in all cases where certain pieces of code to be assembled analog variable text blocks to a variety of target programs. The generative programming allows further also the creation of target programs whose objective parameters at the time of coding the program generator not yet known.

Persistent target code

The object code generated by a program code can

  • Be created once, stored persistently and then used permanently or
  • Be created on demand and dynamically executed and deleted afterwards.

When a destination code is generated once and then kept persistent, the program generation and execution of the target program can take place temporally decoupled. The program generation and execution of the target program is only dependent on one another in so far as the generation prior to the execution of the target code takes place. Code generation is then typically initiated by the programmer or by a system administrator with the software installation, so typically not by the end user.

A regeneration is only necessary if there are changes to the generation parameters.

Dynamically generated target code

In the second case, the program generation and execution of the target code as a rule is triggered directly by the end user. The program generation is ideally carried out so quickly that the end user does not even notice that it intends to use part of the program has been automatically programmed out only a few fractions of a second. The sequence of this dynamic process to be followed in individual steps:

The last step has specific requirements for the programming language used:

  • It must be possible in the program generator to call a routine whose name is specified variable, and is not necessarily known in the context of the program generator. (eg specification of the routine to be called by a string variable, Late Binding)
  • The flexibility in the program calls for generation of an interpreted language, i.e., in general, a code interpreter generates and not a machine code as a destination code. Basically, the target code may, however, be anything, i.e., a source code, intermediate code or binary code.

The target code is generated dynamically usefully often coded in the same language as the codegenerierende program module. A program generator is therefore a specialized to a generic application program class and code generator. It refers to a specific, underlying generic program model, from which it generates the target code after konkretisierender parameterization. A complex parameterization can take place, for example, a model in a database table, which controls the flexible code generation.

Application Examples

UML

UML allows you to create a software architecture in the form of a diagram. It can then be automatically generated code, which must then usually completed "by hand". More sophisticated development environments also enable the simultaneous work on the UML and source code level. One can then optionally change the UML or the source code and development environment automatically creates the other representation of the program. This so either UML code is generated from the source code, or vice versa.

Using XML and XSLT

Even with XSLT is automatic code generation possible. The desired model is represented in an XML document whose syntax you can declare itself. Then you create a matching to the XML document XSLT script to generate the program code. This can also be done in a multistage process, such as one generated by a first XSLT script a batch file, a shell script or a Makefile with a list of additional XSLT processing steps or other commands.

Form generators

Based on a list -like description of the table structure, a screen mask is created from each concrete and predefined tables. Design and operation of the form is fixed. The different tables, however, differ as to the nature and number of fields, the field names, types, and foreign key relationships.

Compiler - compiler

The syntax of a programming language is specified, for example, in EBNF notation. Based on this formal language definition, a compiler - compiler, a parser generator generates the compiler and the parser for the specified language. See also: Coco / R and yacc.

Product configuration

The generative programming can also be used for the processing of bills of materials with variable BOM items. As part of customizing or installing generative programs can bring the variant configuration of complex software applications on the desired target shape.

Rapid Control Prototyping

When rapid control prototyping an adapted for the ECU code is generated, so that errors in the implementation of block diagrams in control unit specific code no longer appear as possible in control engineering from block diagrams.

365710
de