As we have discussed before, re-engineering can involve migrating code to a new dialect of the same language, translating code to a new language, or porting code to a new system. One additional method of re-engineering is something we will term code cocooning. The process of cocooning involves taking a piece of existing legacy code written in one language, and essentially calling it from another wrapper language. This essentially insulates the legacy code, meaning that it is not modified in any manner, and almost exists in stasis. Due to backwards compatibility of languages such as Fortran, there is no issue with compiling the code into an object form, and having the wrapper language access the object code. The wrapper language should be capable of providing proper parameter passing.
Here is an example. Consider a series of three Fortran (F77) subroutines used for biomass computation¹. The three subroutines are RATIOS, STEM and NSTEM, used to perform the required computations for determining the dry weights of wood and bark for various components of a tree. The functions all work, but require a main program to interface data and produce results. Let’s say this main program was written in Julia. By cocooning the Fortran code, it does not need to be modified in any way – the Julia program will access the object code generated, and perform its functions accordingly.
Another more drastic approach is a process we call entombing. This is when then unmodified legacy functions are encapsulated within a newer dialect of the language in question. For example if the Fortran 77 functions from the example above were encased in a Fortran 2003 layer. From the users perspective, the functionality of the legacy code is available, yet the code is entombed – again there is not requirement to modify the legacy code in any way (unless it contains things like older “C” comments, or deleted features).
Of course neither of these techniques is perfect, but they offer a mechanism for re-engineering that may work in certain circumstances.
¹Singh, T., Campbell, D., “Fortran Subroutines for Biomass Computation”, Note No.22, Northern Forest Research Centre, Canadian Forestry Service, Environment Canada (1983)