Alex said:
I need to transfer a Visual Basic program to C++ (stop laughing at the
use of VB, as I didn't write it). The program in question is ~3500
lines long, so it would be VERY unpleasant to convert it by hand. In
adition, only the sintax on a line to line basis needs be transfered as
this program is almost entirely computational, no UI or anything more
complicated than If, For, Case and While statements. Essentially, I am
looking for a sintax converter. Does anyone know of any?
If the program is purely computational, follow this strategy. Download a
light C++ unit test rig, such as NanoCppUnit or CppUnitLite.
(CppUnit itself is hard to use, and somewhat derivative.)
Write a test case that calls system() or popen(), and calls the legacy VB
program's executable.
Pass to that program its simplest possible input. Collect the output into a
string, or something, and parse out its numbers.
(At this point, if you are completely adept at ActiveX, you could build a
DLL in VB and call it from ATL in C++, but don't even start without at least
a year's experience in COM in C++...)
Now your test case is going to call a new C++ function, that does not exist
yet. Pass into the function that same simplest input, and collect its
output. Write an ASSERT_EQUAL() statement that matches the new output to the
legacy output.
Run the test and predict failure.
Now add the minimum amount of C++ code required to pass that test.
Write another test case, and repeat this procedure for each of the source
code's abilities.
Stop occassionally to refactor the C++, running the tests after the fewest
possible edits. Extract duplicated statements into new methods. Along this
process, objects may appear. They might not be the same as the objects in
the legacy VB code. This is a good thing.
I used that technique, between BASIC and Ruby, to extract an old LParser
algorithm and produce this project:
http://flea.sourceforge.net/