473,769 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 22 '05 #1
5 1489
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
Jul 22 '05 #2
"David Goldsmith" <dg***********@ alumni.brown.ed u> wrote in message
news:78******** *************** ***@posting.goo gle.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
Jul 22 '05 #3
"Ivan Vecerina" <NO************ *************** *******@vecerin a.com> wrote in
message news:co******** **@news.hispeed .ch...
"David Goldsmith" <dg***********@ alumni.brown.ed u> wrote in message
news:78******** *************** ***@posting.goo gle.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/fa...-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.

Jul 22 '05 #4
"David Goldsmith" <dg***********@ alumni.brown.ed u> wrote in message
news:78******** *************** ***@posting.goo gle.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
Jul 22 '05 #5
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" <de*******@nosp am.donkim.info> wrote in message news:<1v******* ************@ne wssvr14.news.pr odigy.com>...
"David Goldsmith" <dg***********@ alumni.brown.ed u> wrote in message
news:78******** *************** ***@posting.goo gle.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

Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2598
by: Bozo Schmozo | last post by:
Can someone please recommend some good books on developing web sites (pretty much from scratch) running PHP and the necessary/usual components required, such as MySQL, Apache and etc? As well, does PHP have some good IDE I can use? Any books, online resources or tutorials on developing and getting a web site off the ground using PHP would be much appreciated. TIA!
6
2590
by: Hrvoje Blazevic | last post by:
Are there any good books on Interpreter/Compiler construction, using Python as a defining language out there? Something like Essentials of Programming Languages 2e ? I would appreciate some pointers -- Hrvoje
2
2300
by: Mario | last post by:
Hi, I'm experiencing a nasty problem with Visual Studio .Net 2003. Most Online Resources in the Start Page doesnt work, showing the following message: "This feature requires that you have connected to the internet previously or are currently online"
0
3815
by: sjgrad03 | last post by:
Hello dBforums members: I want to know what reference books are good for perparing for OCA and OCP exams. I found two by OraclePress
4
1264
by: Bozo Schmozo | last post by:
Can someone please recommend some good books on developing web sites (pretty much from scratch) using ASP and the necessary/usual components required, such as XML, C# and etc.? As well, if I have one of the latest versions of Visual Studio, is that all I need as an IDE for ASP/ASP.NET and etc? Any books, online resources or tutorials on developing and getting a web site off the ground using ASP would be much appreciated. TIA!
2
1664
by: Krimgelas | last post by:
Hello, I have been programming in PHP for a while, but always the classic function oriented approach. I would like to learn how to program in PHP with an object oriented approach, but so far have found little resources. I would prefer to find a paperback book that explains this approach in a clear way, without it being too simple or too advanced. Can anybody recommend me some good resources on this matter? Thanks,
6
376
by: Mads Peter Nymand | last post by:
Hi everybody, I am looking for a good C# book. My background: I have half a year of professional experience with Java. I am new to C#. Before that I have been coding a lot in Java, so I am familiar with almost all concepts in Java (J2SE not J2EE). Books that I don't like: · Are full of typos and errors.
0
3668
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. · When was the first version of .NET released? The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on...
0
1070
by: S.Tedeschi | last post by:
Hi all, as already posted, I'm converting an app and I'm facing tons of cons. One of them is my .aspx files can be used by ComponentDesigner to load, e.g., SelectCommands' CommandText, but when I try to run the WebSite, the 1st time is needed a resource, an exception is thrown , stating "Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "TessHockey.wfrmRiservato.resources" was...
9
2228
by: Daniel | last post by:
Looking to see if anyone can offer some suggestions on some good VB.net books? looking for beginner to intermidiate and to expert.. Any suggestions? -- ASP, SQL2005, DW8 VBScript
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.