Template-Based Code Generation System with Syntax Checking

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing code generation tools are complex and inflexible, often requiring developers to manage global variables and learn specific syntaxes, leading to less portable and reusable code, with a two-stage process from template to meta-program and then to executable code, which is cumbersome and error-prone.

Innovation Solution

A template-based code generation system that uses reusable, customizable templates with simple syntax, allowing developers to create and check templates for errors, featuring a code composer with an API, data manager, and template processor to generate executable code directly, using local variables and metadata parameters for customization.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If a two-stage code generation process (template to meta-program, then meta-program to executable code) is used, then code generation becomes more flexible with local variables, but the process complexity increases significantly

Engineering Contradiction:
Improvecode generation flexibilityVSAvoidgeneration process complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent extracts and removes the intermediate meta-program stage from the code generation process. The template now generates executable code directly in a single stage, eliminating the need for meta-program compilation and data assignment through intermediate processing, thus reducing process complexity while maintaining flexibility through local variables and template parameters

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent segments the template into distinct functional components: template definition, parameter declaration, local variable definition, and code generation logic. This segmentation allows each component to be independently managed and processed, enabling direct generation of executable code without requiring an intermediate meta-program stage

Inventive Principle:
Principle #1Segmentation

2Ease of operation

If global variables are used in code generation tools, then code generation can be achieved with simpler syntax, but portability and independence are reduced

Engineering Contradiction:
Improvesyntax simplicityVSAvoidcode portability
Core Design Contradiction:
Ease of operationVSAdaptability or versatility

Solution Approach 1:

The patent applies local quality by introducing local variables within the template scope instead of using global variables. Each template has its own isolated variable environment, allowing the same template to be used in different contexts with different data assignments, thus improving portability while maintaining simple syntax through the template language

Inventive Principle:
Principle #3Local quality

Solution Approach 2:

The patent creates universal templates that can generate different executable codes for various applications by using parameters and local variables. The same template structure can be reused across multiple projects by simply changing the input data and parameter values, eliminating the need for global variables and improving code portability

Inventive Principle:
Principle #6Universality (Multi-functionality)

3Productivity

If templates include mixture of code to produce meta-program and code to produce executable code, then code generation can be achieved, but the template becomes confusing and less reusable

Engineering Contradiction:
Improvecode generation capabilityVSAvoidtemplate clarity
Core Design Contradiction:
ProductivityVSEase of operation

Solution Approach 1:

The patent extracts and removes the meta-program generation code from the template, leaving only the executable code generation logic. The template now contains purely the code that will be executed, making it clear and reusable without confusing meta-programming constructs

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

Instead of generating meta-program code that later produces executable code, the patent inverts the approach by having the template directly generate executable code. This reversal eliminates the confusion of mixed code types and makes templates more reusable across different applications

Inventive Principle:
Principle #13The other way round (Inversion)

Data Source

PatentUS8091071B2Method and system for template-based code generation
Publication Date: 2012.01.03 SAP SE
  • US8091071B2 patent drawing
  • US8091071B2 patent drawing
  • US8091071B2 patent drawing

AI summary

A method and a system for template-based code generation. The method easily renders executable code using reusable customizable templates. The method further checks the templates for syntax errors prior to use. The system provides a memory and a processor for implementing template-based code generation.