How to manage code conversion? [closed]
Asked Answered
P

1

5

I have to convert an application with about 100k lines of code from one programming language to another (java to c++).

I'm looking for a solution to track my progress and make sure that nothing falls through the cracks.

So far I've thought about two approaches, but neither seems to be optimal:

  • copy the old code as comments into the new source files, and delete the portions that are converted (this gets messy)

  • print out the old code, and use a highlighter to mark converted code (not efficient)

Probably the best solution would be some text editor where I could keep the old code base and digitally highlight/mark up the code that's already converted. Does a utility like this exist? Or is there a better solution for managing code conversion?

Perdue answered 13/9, 2013 at 21:59 Comment(5)
Depends strongly on the language being converted from and to.Meperidine
Are either good ideas? Why aren't you just translating it and testing that all outputs are identical?Mantic
Is there going to be any effort to refactor or redesign any portions of the code base? This could also cause some issues keeping track of where you're at.Chance
Converting from java to c++ (info added to question).Perdue
@Brian: Yes, there are areas that can use some refactoring/improvement. It does make it more challenging.Perdue
Z
7

You can check your old code into a VCS (e.g. Git, SVN, etc.), then start deleting the parts which you've already converted. The VCS diff tool will tell you clearly what parts have been deleted, acting like this "digital highlighting" approach but simpler (because the old code base will shrink as you convert it).

The most pragmatic approach would be to convert the tests first (if you have any tests...). Then you can write the new code against the tests. If you don't have tests, strongly consider making some. Converting 100KLOC without tests is a recipe for subtle bugs months later.

Zampino answered 13/9, 2013 at 22:2 Comment(2)
Converting that much code is going to be a mess regardless :> I agree with the test-and-build-approach.Convenance
Thanks so much for the suggestion! That's a great solution. And no, there are no tests for the old code, and yes, I need to make some.Perdue

© 2022 - 2024 — McMap. All rights reserved.