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 2 2067
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
In article <bd**********@n ews01.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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 have at hand is that I want to specify 'has a' and 'has many'
relationships in an array for each class and use these to automagically
create the accessor methods and perhaps mutator methods as well.
|
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 Get<whatever> function)
2) for each data member, the class will have a mutator member function
(a Set<whatver> function)
3) data members are never referenced directly; they are always
referenced with the accessor and mutator functions
My questions are:
|
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 almost never
an excuse for accessor methods. Personally, I do not go that far. I
do feel that they serve a useful purpose (albeit in a limited manner).
Personally I prefer dropping the "set" and "get" prefixes from the
method names altogether. ...
|
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 (also copied below for easier reference):
http://groups.google.it/groups?hl=en&lr=&safe=off&selm=6beiuk%24cje%40netlab.cs.rpi.edu&rnum=95
I don't agree anymore.
|
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
| |
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. What is the normal way to
do this?
Thanks,
Thomas
--
|
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 for those methods which
are not called in any of my assemblies.
1) I want to remove all methods (either private,
|
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 the only thing I can't
migrate is my Access databases.
I'm looking to export them in a standard file format, then provide
convert functionality into SWT, Flash, HTML, Native and/or some other
formats.
|
by: Tim Sprout |
last post by:
Why is it considerd best practice to use Properties rather than Get and Set
accessor methods?
-Tim Sprout
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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...
| |