Automatic Code Generation and Code Reusability

International Journals of Advanced Research in
Computer Science and Software Engineering
ISSN: 2277-128X (Volume-7, Issue-6)
Research Article
June
2017
Automatic Code Generation and Code Reusability through
Software Clone Repositories
K. Vidhya, Dr. MCET
Anna University, Tamil Nadu,
India
A. Brunda, Dr. MCET
Anna University, Tamil Nadu,
India
Abstract: Software development companies are assigned with a variety of projects with diversified areas and contexts.
It happens that the service based companies may get projects similar to what they have developed already. A set of
modules in the new projects may exactly have the functionalities of what they developed in the previous projects.
Sometimes the modules may match with the functionality of modules in different projects. The project to be developed
may use different programming language compared to the existing projects. This automatic code generation system
aims to translate the software code from existing language to the target language. The system creates a functional
software clone in the required programming language. The key challenge is to identify the clone module (that is the
module which does the required function) from the code repository. Then it may be translated to the programming
language of the project being developed using this automatic code generation system.
Keyword: Code repositories, Automatic code generation, Module and file level clones
I. INTRODUCTION
Software reuse is a process of developing new software systems from existing code instead building software systems
from scratch (5). Software code reuse assures not only increased efficiency but also improved software quality and better
maintainability (5).
Purpose of software development is devising a solution to the real world problem. Service based software development
companies develop projects based on the customer’s needs and requirements. All the projects cannot be coded in the
same programming language or framework. Based on the requirements, purpose and the environment it is to be deployed
the framework is selected. Sometimes this may happen that some common functionality may exist among projects.
Functionalities of some modules of the project to be developed may match with the modules of the projects that are
developed already by the company. The projects may be developed in the same or different programming language
compared to the projects developed so far. In case of same programming language the matching modules may be taken
from the repository and used as such with necessary minor modification. Otherwise it should be coded again in the new
programming language. Instead the module taken from the repository could be converted into the programming language
proposed for this project. This automatic code conversion may increase the productivity and reduces the usage of
resources in terms of cost and time.
II. CODE REPOSITORIES
Code repositories are the databases where the software codes developed by the company are stored. Code repositories
maintained in each company plays a vital role in software reuse. Sometimes the company may get similar type of project
and in that case already coded module or file can be reused in the new project which reduced the project development
time and increased the productivity.
Code repositories may be maintained programming language wise. Once the project is completed, the modules of the
project are taken and named by the functionality it does and stored in the particular language repository. This should be
done appropriately by the project manager; Project manager has the complete thorough knowledge about the project.
These code repositories have several advantages like code reusability and code may be taken even if the project manager
is migrated.
The key challenge here in this system is identifying the right module from the repositories. The success of this system
depends on the appropriateness of the storage and the searching system. The manager of the new project has to decide on
the modules to be developed for the project. Then he/she has to search in the code repositories. Searching should be done
in all the language repositories. The searching system should search for the files based on the given functionality name,
since files are named based on function what it does. It should also consider the synonyms of the file name to make the
searching more accurate.
III. CODE GENERATION SYSTEM.
In present scenario, industries are migrated towards automation .Automatic code generation is a standard method in
software engineering, improving the code reliability as well as reducing the overall development time. Using a code
generator always implies spending additional time on the code generator rather than programming an application
manually. The advantages of automatic code generation system is increased productivity with minimal resources (8)
© www.ijarcsse.com, All Rights Reserved
Page | 532
Vidhya et al., International Journals of Advanced Research in Computer Science and Software Engineering
ISSN: 2277-128X (Volume-7, Issue-6)
The module retrieved during searching operation may be in the same programming language of the proposed project or
may be retrieved from some other repository. Module/file retrieved from the same programming language repository may
be used as such or with minor modification. Otherwise the code should be converted into the target language. The block
diagram of the system is given below
Figure 1 Block diagram for code generation system
The file to be retrieved is searched in all repositories and if file is not found then the system declares that the module with
the required functionality is not available. Then the programmer should code that module and may be stored in the
repository for future reuse.
The file is retrieved and if it is in some other language then the automatic code generation system creates a clone of the
existing module in different programming language. Software clones are the piece of codes which does the same
function.
The key objective behind this system is that already resources spent on developing solution to the same problem and the
idea is owned to that particular company. In future if company gets the similar type of projects then the modules coded
previously may be reused. Even if the programming language is different, the concept is same. So the code may be
converted to the target programming language.
This automatic code generation system converts the code for Java, Python and C# languages. The module taken in any if
these 3 languages may be converted to any of the other 2.The conversion is done line by line considering the syntax of
the language. The code generation system is shown in figure 2.
Figure 2 Code Generation system
© www.ijarcsse.com, All Rights Reserved
Page | 533
Vidhya et al., International Journals of Advanced Research in Computer Science and Software Engineering
ISSN: 2277-128X (Volume-7, Issue-6)
If the selected option is searching then it asks for the module to be searched and one or more repositories are selected as
given in figure 3 and 4
Figure 3 selecting the repository in which module to be searched
Figure 4 Searching for modules in code generation system
Once the searching is completed and if the file is not available in any repositories the system displays the message
module not found and if the module is found in any one of the repositories or more than one repository then the
repository names are displayed as given in figure 5 and 6
Figure 5 System displaying the message “module not found”
© www.ijarcsse.com, All Rights Reserved
Page | 534
Vidhya et al., International Journals of Advanced Research in Computer Science and Software Engineering
ISSN: 2277-128X (Volume-7, Issue-6)
Figure 6 System asking for target language to be converted
Once the target language is selected the system converts the existing code to the target code and it is updated in the
appropriate programming language repository.A sample code converted from Java to C#.Net is given in table 1
Table 1 Java code to add 2 numbers is converted to C#.Net code
iimport java.io.*;
using System;
class Addition
class Addition
{
{
public static void main(String args[])throws Exception
static void Main(string[] args)
{
{
int x;
int y;
int x;
int result;
int y;
System.out.println("("\n Enter the first number to be
int result;
added: "");
Console.Write("\n Enter the first number to be added:
BufferedReader br= new BufferedReader( new
");
InputStreamReader(System.in));
x=Convert.ToInt32(Console.ReadLine());
x=Integer.parseInt(br.readLine());
Console.Write("\n Enter the second number to be
System.out.println("("\n Enter the second number to be
added: ");
added: "");
y = Convert.ToInt32(Console.ReadLine());
y=Integer.parseInt(br.readLine());
result = x + y;
result=x+y;
Console.Write("\n The sum of two numbers is:
System.out.println("\nSum The sum of two numbers
"+result);
is:"+result);
Console.ReadLine();
}
}
}
}
IV. CONCLUSION
Automatic code generation system helps the service based software companies when they get similar type of projects.
This system incorporates the advantages of automatic code generation, software clones and software reuse. The system
increases the efficiency and productivity and reduces the usage of resources in terms of cost and time
REFERENCES
[1]
Alan MacCormack, John Rusnak, Carliss Baldwin, The Impact of Component Modularity on
Design
Evolution: Evidence from the Software Industry, http://ssrn.com/abstract=1071720
[2]
Gennari J.H., Tu S.W., Rothenfluh T.E., Musen M.: "Mapping Domains to Methods in Support of Reuse".
International Journal of Human-Computer Studies. 41, 399-424. 1994
[3]
Jalender B,Dr Govardhan A, Dr Premchand P Designing Code Level Reusable Software
Components,
International Journal of Software Engineering & Applications (IJSEA), Vol.3, No.1, January 2012
[4]
Kavitha
Esther
Rajakumari1
,Dr.S.Srinivasan”Role
of
Functional
Clones
in
Software
Development”,Proceedings of 2015 International Conference on Future Computational Technologies,March 2930, 2015, pp. 41-47
[5]
Manuel Sojer, Joachim Henkel, Code Reuse in Open Source Software Development:Quantitative Evidence,
Drivers, and Impediments, http://ssrn.com/abstract=1489789
© www.ijarcsse.com, All Rights Reserved
Page | 535
[6]
[7]
[8]
[9]
[10]
Vidhya et al., International Journals of Advanced Research in Computer Science and Software Engineering
ISSN: 2277-128X (Volume-7, Issue-6)
Martin Molina, Jose L. Sierra, Jose Cuena, Reusable Knowledge-based Components for Building Software
Applications: A Knowledge Modelling Approach, International Journal of Software Engineering and
Knowledge Engineering, Vol. 9 No. 3 (1999) 297-317
Shireesha, Sharma, Building Reusable Software Component For Optimization Check in ABAP Coding,
International Journal of Software Engineering & Applications (IJSEA), Vol.1, No.3, July 2010
Christopher Pohl, Carlos Paiz, and Mario PorrmannvMAGIC—Automatic Code Generation for VHDL,
International Journal of Reconfigurable Computing Volume 2009 (2009), Article ID 205149.
Vidhya k, Thirukumar K, Identifying Functional Clones Between Java Directories Using Metric Based System,
International Journal of Advanced Research in Computer Science and Engineering, Vol. 3,Issue 8,Aug 2013.
Vidhya k, Brunda A, Deployment of Modularity to Enhance the Software Code Reusability by Maintaining
Code Repositories for Multiple Programming, International Journal of Advanced Research in Computer Science
and Engineering, Vol.6,Issue 6,June 2016
© www.ijarcsse.com, All Rights Reserved
Page | 536