{'fraction_non_alphanumeric': 0.02442244224422442, 'fraction_numerical': 0.0030803080308030805, 'mean_word_length': 4.973718791064389, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Automated Code Generation Using Case-Based Reasoning, Routine Design and Template-Based Programming

Automated code generation is the process whereby a computer program takes user specifications in some form and produces a program as output. Automated code generation can be the process undertaken by a compiler, which generates an executable program from a source program, but it also applies to the situation where the input is a task described at some level of abstraction and the output is a program that can perform that task. Several different approaches have been utilized to varying degrees of success to automate code generation, including CaseBased Reasoning, formal methods and evolutionary algorithms. In this paper, a system is introduced which combines Case-Based Reasoning, Routine Design and Template-Based Programming to generate programs that handle straight-forward database operations. This paper presents the approach taken and offers some brief examples. Automated code generation (ACG) is the process whereby a computer program takes user specifications in some form and produces a working program as output. When the user input is some abstract description of a task, as opposed to source code in some high level language, ACG presents both a challenging problem and an opportunity to reduce cost. Automating the programming task, which normally requires a great deal of expertise involves employing techniques that comprise design or planning, logic and programming knowledge. The benefits of ACG include reducing or eliminating expenses involved in software development and maintenance, which studies have indicated could cost corporations as much as 10% of their yearly expenses (Jones 2010). One form of ACG is the compiler. The user provides source code as input and the compiler generates an executable program. Compilers have been in regular use since the late 1950s when the first high level languages were developed. Although initially many programmers scoffed at the idea that ACG could produce efficient and correct code, very few programmers today would write code in a low level language, favoring the high level languages and compiler technologies. However, the compiler requires too detailed an input as the programmer must still produce the algorithm in a proper syntactic form. In Artificial Intelligence (AI), a variety of approaches have been explored to support software development. Case-Based Reasoning (CBR), for instance, can be used to maintain a library of code routines (e.g., objects, methods), select the code routines that best match user specifications, and present the those options to the software developer. Alternatively, through genetic and evolutionary programming, code can be mutated and tested for improvements. If improved, the new code becomes a base for the next generation of code. Random changes can potentially lead to code that is more concise, more efficient, or more correct. At present, neither CBR nor evolutionary approaches has yielded an ACG system that can replace a software developer. In this paper, the research focuses on three different but related areas. First, code generation is thought to be a design problem. A solution will be a plan. Plan steps can be specified at a generic level and then refined into more detail. Eventually all plan steps will be filled in with code components from a component library. Once selected, these components are combined and used to fill in a program template. Although the word “plan” is being used, the plan is a description of a solution, or a design to solve the stated problem. The plan steps provide goals to be fulfilled. Code components are selected to fulfill each of these goals. Thus, the problem is one of designing a solution through a code component library. The plan itself is retrieved from a library of plans, based on user specification. Additionally, if the selected plan does not precisely match the user specifications, alterations can be made. The refined plan can be stored for future retrieval. Thus, an ACG system can be built as a combination of Routine Design (RD), Template-Based Programming (TBP) and Case-Based Reasoning (CBR). In this paper, the Automated Coder using Artificial Intelligence (ACAI) system is presented. The paper is laid out as follows. Section 2 identifies related work and some background into both RD and CBR. Section 3 presents the ACAI system. Section 4 contains a brief example and description of the system in action. Section 5 offers some conclusions and future work.