Role of Software Re-Engineering Through C to Java Conversion

Vinod Kumar Yadav *  Ajay Pal Singh **  Satendra Kumar ***
* Assistant Professor, Department of Computer Science and Engineering, SLSET, U.K., India.
** Assistant Professor, Department of Computer Science and Engineering, DBIT, UP, India.
*** Assistant Professor, Department of Computer Science and Engineering, SITM, Haryana, India.

Abstract

Re-engineering is used to support evolutionary maintenance and it is most widely used in modern software development. The Re-engineering occurs at two level of abstraction: at business level and at software level. The term maintenance should be replaced by “re-engineering” or renovation or reclamation because it not only recovers information from existing system but uses this information to alter or reconstitute the existing system in an effect to improve its overall quality. The source code translation is one of the main tasks in software reengineering which is based on source to source transformation which plays an important role. If we want to migrate a procedural language into object oriented programming language because of its reusability of code, the code conversion is necessary due to hardware platform update, staff skill shortage and organization changes.

Keywords :

Introduction

Changing any software product is a life time activity so the software industry mostly uses re-engineering activity to enhance performance and quality of software. The Software systems must continually evolve to meet ever- changing needs. However, such systems often become legacy systems as a consequence of uncontrolled maintenance combined with obsolete technology. To control maintenance costs and preserve complex embedded business rules, companies must evolve their legacy systems (Ebert 2011). Re-engineering consists of following three stages: reverse engineering, restructuring, and forward engineering. Re-engineering is the most widely used approach to support evolutionary maintenance. It examines and alters a legacy system to reconstitute it in a new form (Roger [1]).

The re-engineering is the systematic transformation of an existing system to realize the quality improvement in operation, system capability, functionality, performance and to reduce risks. The main objective of software reengineering is to ease the changes and to reduce maintenance cost of given legacy system. The Object oriented systems can be easily upgraded from small to large systems. The essence of software reengineering is to reuse the existing code of the legacy system because the original expense of developing the logic and components of software should not be wasted. Legacy systems are old software systems which are essential for business process support. The modification and maintainability of these systems is very difficult. Such systems represent a challenge for software engineers to software evaluation. The Reverse and re-engineering technologies are used to uncover the structure of legacy system and restructuring to improve it.

We can convert a procedural language like C to object oriented language like java manually as well as by conversion tool. However, the overall quality of converted code is degraded because generated code in java takes more Line of Code (LOC) then manually converted code but it saves time and cost. If we ignore LOC than quality of generated code is certainly improved because generated code by tool having most of the object oriented programming feature like reusability, polymorphism, portability, user friendliness etc. Reusability is one of the most important features of generated code in java. We can eliminate redundant code and extend the use of existing classes.

There are various re-engineering tools such as Modisco, Amelio, Clone-DR, Moose, Ephedra, Novosoft's C2J and C2J++ etc. C2J and C2J++ are very similar, however some functionality are different and they are discussed later. As explained in Java language specification, java is related to C and C++ but there are some important and noticeable differences between C and C++ or C and Java language. This is the main reason that poses some problems in a migration from C to java language. The biggest difference is that C is procedural language while java is Object oriented language.

1. Literature Review

There are many research works done by various researchers as follows:

Eunjoo Lee et. al [3] found during their research work that component based systems are more reliable and less expensive than an object oriented legacy system. Computing environments are evolving from standalone mainframe systems to distributed systems. Many legacy systems today are object-oriented and component-based. One of the most prominent maintenance objectives is system migration to distributed environments. Granularity is the ratio between work in parallel and whole work. It can be calculated by following formula:

Granularity = work in parallel / whole work

Due to lack of methods for Re-engineering of an object oriented system we convert these systems into component based system. We know that distributed development is based on the component based system. So granularity of distributed development is more than object based system because the granularity of course grain system is more than fine grain system (object oriented system). The development of distributed system is more and more based on the use of component technology.

Aniello Cimitile et. al 1999, identified that for reducing the development and maintenance cost, many organizations are migrating towards object-oriented technology. When we move from the centralized mainframe system towards distributed client-server platform the cost is so much reduced. However, owing to the business value of legacy software, new object-oriented development has to be weighed against salvaging strategies. The incremental migration of procedurally oriented systems to object-oriented platforms seems to be a feasible approach, although it must be considered as risky as redevelopment. This approach uses reverse engineering activities to abstract an object-oriented model from legacy code. The paper presents a method for decomposing legacy systems into objects.

Erik D. Demaine [6] explained in his research paper “C to Java: Converting pointer into references” how to remove pointers from a given program. He explained how to convert various scientific applications developed in C language into java language. He also proposed a general model which is implemented directly in java language. Removal of pointers becomes mandatory if we want to convert a given C application to java language because there is no use of pointers in java language. The pointers are replaced by references in java language. C language is very popular language for the stand alone application programs. If we want to extent such programs or want to port an application to java for demonstration on World Wide Web (WWW) then C language is not suitable. The main reason is that C is not used for web applications because of its pointers.

Dr. Ashok Kumar, Bakhshsish Singh Gill [7] focused on difference between software maintenance and software re-engineering during their work. Software maintenance and software re-engineering are the existing terms in software engineering; these are very hot term and closely related to each other. They presented following four models to differentiate them: cost comparison model, thoroughfare differentiation model, Object based model and discrete model. Re-engineering reduces the expenses on software systems in the organizations. Re-engineering has more scope in the world of software than in the world of hard ware objects. Software systems and software objects do not wear and tear out like hardware objects in the real world. Maintenance is close to repair/mend where as reengineering is very close to new development.

Xinyu Wang, Jianling Sun et.al [5] has presented a new process to reengineer C++ legacy system into the J2EE partition distributed system. The process consists of following four steps: translation from C to Java code; Extraction of component using the clustering technology; Modeling component interfaces and partition of component in J2EE distributed environment. There are various systems developed by several enterprises and most of them are standalone systems. The standalone systems are those systems which can not follow the new market environment. So if we want these to be re-engineered then it is a critical problem. There are two options to migrate legacy systems to new platforms or frameworks. One approach is the complete redevelopment of legacy systems with new functional specifications or use cases. The other is evolutionary migration of current legacy systems.

Indravadan S. Patel & Vandana A. Verma (2012) focused on software privacy and prevention of piracy. They also explained, “What is the meaning of software piracy and why do we protect our software from piracy?” Piracy or unauthorized production became a danger for software sector now-a-days because many unauthorized software product are available in market. They defined Source code as Source code is text written using the format and syntax of the programming language as C. The software architecture is not updated so distributing centralized systems is difficult. It is not usually possible to radically change the system programming language so old legacy systems cannot be converted to object-oriented programming languages such as Java or C++. Figure 1 shows the Re-engineering process.

Figure 1. Re-Engineering Process [8]

In source code translation, the program is converted from an old programming language to a more modern version of the same language or to a different language.

2. Conversion of C to Java by C2J Tool

Novosoft's C2J converter provides an automatic translation of C source code files to separate java classes with appropriate names. C2J is being developed using C language but its compiler is available as native executable for Win 32 as well as java application which runs where JVM is implemented (i.e. on win 32, UNIX etc.). If we installed C2J using wizard, the system variables have been set automatically, otherwise we have to check system variables (Martin Johannes, 2001).

Now they have presented the result of different case studies which they have found during their experimental work. In these case studies they have also presented the types of difficulties that come during the work and what types of efforts are done by them. They have concluded this case studies by selecting different types of C program and converted them by tool directly as well as after doing some manual work on that C code that is to be converted by C2J tool. This tool offers automatic migration of frequently used standard library functions.

We also had drawn a comparison graph which is based on our result of experiential work. This graph is not based on the performance of the generated code, this is based on the Line of Code (LOC) used in different situations. We also concluded that for small number of lines in C code its java equivalent code is high and if we increase LOC of C language then in that situation LOC of generated java code increases in a constant way not enormously because in starting it checks different exceptions, and built different equivalent java classes. Figure 2 shows comparision graph based on LOC of C & JAVA. First it creates java class with the same name of C class after that it uses different functions like try (), catch(), throw new Exception () etc. Once the exceptions are handled they can be thrown from the program. They may appear, but actually they are not executed by java compiler.

Figure 2. Comparision Graph Based on LOC of C& JAVA

3. Removal of Pointers From C Programs

The objective of case study is to determine:

In C language, the arguments to the functions can be passed in the two ways:

(a)Call by value (b) Call by reference

In call by value original value of function does not change, because they reside at different memory locations having different address in memory.

There are two types of parameters: actual parameters and formal parameters. In call by value method, the changes made to the formal parameters only and actual arguments remain unchanged. On the other hand, in call by reference method, any changes made to the formal arguments change the actual arguments. Figure 3 shows the Snap shot of C code.

Figure 3. Snap shot of C Code

3.1 Efforts Used By Us to Resolve Pointers

The output of converted code using call by value method having no pointers is shown in Figures 4 and 5, which cannot be converted without removing pointers from original C program.

Figure 4. Snap shot of C2J

Figure 5. Output on JDK 1.6 of converted java code

The actual output from converted code from above C code from call by value method is given below:

3.2 Observations during Resolving Pointers

If we try to convert any 'C' program having pointers into java by tool, then it is not possible without resolving pointers.

Total effort= manual work + machine time

Machine time = compilation + generating time

Manual work is not constant, it depends on LOC having pointers, and machine time always varies. So total effort as well as manual effort are not constant but in observation of C2J manual effort is constant however total effort depends on LOC in original C program as well as structure of program.

Conclusion

LOC of generated code in java by tool with a little manual effort not only depends on LOC of original C source code but it also depends on the nature of C source code. Goto Statements program take more LOC in generated code by C2J in comparison to other C code having same LOC. Switch has more LOC in C, but it takes relatively less LOC in generated code by tool because in java switch statement is written in similar way of C. Similar program having different LOC takes approximate constant manual effort during C to java conversion.

Future Scope

In near future, it may be possible to convert code between two platforms which are completely different with each other. So, when we click a button at a time, the whole source code should be converted to the source code of the required language and we do not need any manual work during transliteration process. AI can also be applied to achieve more automatic advancement because a single library function cannot do such a conversion perfectly and recognize the replacement criteria in a particular language. Researchers can try to provide the interface between these generated codes by tool and manually written java source code.

References

[1]. Roger S. Pressman, “Software Engineering: A Practitioner’s Approach”, fifth edition, McGraw Hill, international edition.
[2]. Ebert Christof, Perez- Castillo Ricardo et. al (2011). “Re-engineering Technology” November/ December 2011, IEEE Software © 2011 IEEE.
[3]. Fitzpatrick Jerry (1996). “Case study: Converting C program to C++”, Originally published in C++ Report copyright 1996 by Jerry Fitzpatrick.
[4]. Cimitile Aniello, De Lucia Andrea, Giuseppe Antonio Di Lucca, Rita Anna & Fasolino (1999). Identifying objects in legacy systems using design metrics: Journal of Systems and Software, 44 (1999) 199-211© 1999 Elsevier science.
[5]. Tucker D. Casey, Simmonds M. Devon. (2010). “A Case study in software re-engineering” Seventh International Conference on Information Technology, page 1107-1112.
[6]. Demaine D. Erik, “C to Java: Converting Pointers into references”, Department of Computer Science, University of Waterloo, Canada.
[7]. Koschke Rainer, Cordy James, Jarzabek Stanislaw, Inoue Katsuro (2009). “Third International Workshop on Software Clones (IWSC)” 09 European Conference on Software Maintenance and Re-engineering, IEEE.
[8]. Indravadan S. Patel, Vandana A. Verma (2012). “Software Re-engineering Piracy Issues of Code Translation by End User”, International Journal of Research in IT & Management, Volume 2, Issue 2.
[9]. Martin Johannes & Muller A. Hausi (2001). “Strategies for Migration from C to Java”, IEEE, 25th European conference.