"David Goldsmith" <dg***********@alumni.brown.edu> wrote in message
news:78**************************@posting.google.c om...
Any reference material recommendations discussing issues arising in
the reengineering of a legacy, structured-style C program to an OO C++
program?
The first step should be simple: just compile the code as C++, then
understand and fix any errors that will show up.
Beyond this, any change needs to be motivated by a specific goal.
If it works, don't touch it!
When changes are required, the right approach is project dependent.
Do you just need to introduce a base class interface so you can
add subclasses? Do you have to add an abstraction layer to port
the application to a new platform?
Language-independent references about code refactoring and (domain
specific) design patterns may provide some guidance.
Many C++ techniques can also help make the code more maintainable:
replace macros with inline functions and other constants; replace
function pointers with polymorphic interfaces; use constructors and
destructors instead of manual initialization/freeing; use RAII for
resource management; etc.
The main caveat when you have a mix of C++ and C style code is
error handling and memory management. As soon as a function
can generate (C++) exceptions, all calling code needs to be
exception-safe (e.g. use the RAII idiom).
This means that you need to carefully maintain interfaces
between C style and new C++ functions.
hth,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com