473,471 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Tool to convert public mem var RWs to use accessor methods?

I've inherited two "C++" code bases that I have to tie together
and both of them make frequest use of public member variables
in spite of all the information saying this limits flexibility. Well,
their lack of foresight has bit me of course! I'd like to start off
by converting all their public member variable accesses to the
use of accessor methods. Then, I can reimplement selected
accessor methods to provide the necessary glue between the
code bases.

The question is....is there a tool that can automatically perform
this sort of transformation to accessor methods from public
member variables?

thanks,

Todd
Jul 19 '05 #1
2 2045
Sounds like a job for regular expressions, e.g., in C++ or Perl.

Todd A. Anderson wrote:
I've inherited two "C++" code bases that I have to tie together
and both of them make frequest use of public member variables
in spite of all the information saying this limits flexibility. Well,
their lack of foresight has bit me of course! I'd like to start off
by converting all their public member variable accesses to the
use of accessor methods. Then, I can reimplement selected
accessor methods to provide the necessary glue between the
code bases.

The question is....is there a tool that can automatically perform
this sort of transformation to accessor methods from public
member variables?

thanks,

Todd


Jul 19 '05 #2
In article <bd**********@news01.intel.com>, dr****@aaahawk.com says...

[ ... ]
The question is....is there a tool that can automatically perform
this sort of transformation to accessor methods from public
member variables?


I don't know of anything that does it entirely automatically, but right
now operator overloading just became one of your best friends.

Instead of attempting to find every place every variable is used, look
only for where they're declared, which is usually a LOT easier. Convert
each from its current type to an instance of a class that overloads
operator=(T const &) and operator T (where T is the original type).
These are your new "accessor" functions -- operator T converts your type
to the original type just before its value gets assigned, and operator=
gets called (of course) to assign some value to your object.

IMO, even if this didn't save a tremendous amount of work, it would
still be the way to go -- using accessor and mutator functions is almost
always quite ugly.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #3

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

Similar topics

6
by: jerrygarciuh | last post by:
Hello, I have been working for some time now on a PHP OOP database abstraction layer. Yes I know there are others out there which are maturing but I like reinventing this wheel. The task I...
22
by: mirandacascade | last post by:
When I look at how classes are set up in other languages (e.g. C++), I often observe the following patterns: 1) for each data member, the class will have an accessor member function (a...
22
by: Generic Usenet Account | last post by:
A lot has been said in this newsgroup regarding the "evil" set/get accessor methods. Arthur Riel, (of Vanguard Training), in his class, "Heuristis for O-O Analysis & Design", says that there is...
10
by: Zap | last post by:
Widespread opinion is that public data members are evil, because if you have to change the way the data is stored in your class you have to break the code accessing it, etc. After reading this...
3
by: James | last post by:
Has anyone written a utility to convert a C# form to C++.net? i.e. to convert "using System.Data" to "using namespace System::Data" etc
27
by: thomasp | last post by:
Variables that I would like to make available to all forms and modules in my program, where should I declare them? At the momment I just created a module and have them all declared public there. ...
5
by: Venkat | last post by:
Hi, My application is splitted into more than one assembly. And I want to clean up the methods which are not called or not used among any of the assemblies. And also I want to remove the code...
7
by: dtecmeister | last post by:
Looking to see how many people could use this kind of tool. I've got several large databases I've developed in Access with MySQL as the back-end. I've started using Linux instead of windows and...
8
by: Tim Sprout | last post by:
Why is it considerd best practice to use Properties rather than Get and Set accessor methods? -Tim Sprout
0
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...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.