| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"David Goldsmith" |
| Date: |
01 Dec 2004 03:24:00 PM |
| Object: |
Books/online resources on converting C to C++ |
Any reference material recommendations discussing issues arising in
the reengineering of a legacy, structured-style C program to an OO C++
program?
DG
.
|
|
| User: "Don Kim" |
|
| Title: Re: Books/online resources on converting C to C++ |
02 Dec 2004 07:41:17 PM |
|
|
"David Goldsmith" <dgoldsmith_89@alumni.brown.edu> wrote in message
news:78dbfced.0412011324.22936e89@posting.google.com...
Any reference material recommendations discussing issues arising in
the reengineering of a legacy, structured-style C program to an OO C++
program?
I don't know of a particular reference, but the book "Thinking in C++"
Volume 1 is definetely a book for those comming to C++ from a C background.
You can download it for free too.
-Don Kim
.
|
|
|
| User: "David Goldsmith" |
|
| Title: Re: Books/online resources on converting C to C++ |
03 Dec 2004 01:37:14 PM |
|
|
Thanks!
As for the very good question (asked previously) "why do it at all?":
because I've been told to! Actually, what we want is to make the code
platform independent AND native using wxWidgets, and, due to extant
in-house expertise, it's to be done in C++; the extant C code has
actually been built using a C++ compiler, but it is devoid of OO
paradigmatic entities, e.g., classes. But, cognizant/empathetic of/to
the "If it ain't broke, don't fix it" viewpoint, I have already
queried my bosses regarding the importance of actually remaking the
whole thing (as opposed to any wxWidgets enhancements/re-do's) OO.
Thanks again!
DG
"Don Kim" <developer@nospam.donkim.info> wrote in message news:<1vPrd.37430$6q2.37193@newssvr14.news.prodigy.com>...
"David Goldsmith" <dgoldsmith_89@alumni.brown.edu> wrote in message
news:78dbfced.0412011324.22936e89@posting.google.com...
Any reference material recommendations discussing issues arising in
the reengineering of a legacy, structured-style C program to an OO C++
program?
I don't know of a particular reference, but the book "Thinking in C++"
Volume 1 is definetely a book for those comming to C++ from a C background.
You can download it for free too.
-Don Kim
.
|
|
|
|
|
| User: "Ivan Vecerina" |
|
| Title: Re: Books/online resources on converting C to C++ |
02 Dec 2004 01:43:10 AM |
|
|
"David Goldsmith" <dgoldsmith_89@alumni.brown.edu> wrote in message
news:78dbfced.0412011324.22936e89@posting.google.com...
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
.
|
|
|
| User: "Ivan Vecerina" |
|
| Title: Re: Books/online resources on converting C to C++ |
02 Dec 2004 01:55:05 AM |
|
|
"Ivan Vecerina" <NOT_VALID_please_use_contact_webform@vecerina.com> wrote in
message news:comh2e$5ih$1@news.hispeed.ch...
"David Goldsmith" <dgoldsmith_89@alumni.brown.edu> wrote in message
news:78dbfced.0412011324.22936e89@posting.google.com...
Any reference material recommendations discussing issues arising in
the reengineering of a legacy, structured-style C program to an OO C++
program?
....
Language-independent references about code refactoring and (domain
specific) design patterns may provide some guidance.
PS:
For technicalities and differences between C and C++, the following
links may be of interest:
http://www.research.att.com/~bs/papers.html (check the "C and C++...")
http://www.ece.utexas.edu/courses/fall_04/ee322c-15515/notes-from-c-to-c++.pdfBut the key is really to understand all the C++ idioms and techniquesyou can use, so you make the right choices when performing changes.
.
|
|
|
|
|
| User: "Victor Bazarov" |
|
| Title: Re: Books/online resources on converting C to C++ |
01 Dec 2004 03:50:48 PM |
|
|
David Goldsmith wrote:
Any reference material recommendations discussing issues arising in
the reengineering of a legacy, structured-style C program to an OO C++
program?
Three approaches I know of:
- Just do it(tm). Simply compile it with a C++ compiler and fix the
errors, if any. C++ is a multi-paradigm language, OO is but one of
them.
- Don't do it. Keep it C. If it worked until now, why change it?
IOW, don't fix what isn't broken.
- Total rewrite. You have to figure out the problem they solved and
re-solve it using a different model or a different implementation of
the same model.
Depending on many factors you use one or another approach, or a mix of
them.
I don't know any references (and why would there be, such problem does
not arise on a daily basis), but I am fairly sure that if you look in
the news archives (groups.google.com) you will find similar questions
asked and answered more than once.
Also, take a peek in comp.software-eng newsgroup, reengineering is more
of their domain than a language issue.
V
.
|
|
|
|

|
Related Articles |
|
|