Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Introduce Using Statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

membry
Junior Member

20 Posts

Posted - Sep 17 2009 :  4:03:17 PM  Show Profile  Reply with Quote
One of the challenges of working on a large legacy C++ project is the overuse of "using namespace <foo>". Along with the consequences thereof.

(1) To go from:

using namespace std;

string text = "refactor me...";

(2) to:

std::string text = "refactor me...";

(3) to:

using std::string;

string text = "refactor me...";

should be a valid C++ refactoring (more so for source files than header files but still valid).

It would be helpful if VAX had a "Introduce Using Statement" refactoring similar to the "Add Include" refactoring where VAX would go from step 2 to step 3 above. I'd prefer that the using statements be added just below includes. Per Sutter et al C++ Coding Standards book.

FWIW, We did consider leaving everything at (2) for source files but some of the namespaces tend to have long names, Google Mock seemingly has a namespace for every other line of their code and boost overloads a lot of operators for which it is cleaner and less confusing to use a using statement anyway.

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Sep 24 2009 :  12:52:04 PM  Show Profile  Reply with Quote
Do you have much code at stage 1?

I see the appeal of this idea, I am just thinking that limiting it to only stage 2 might be unhelpful for people with code at stage 1.

zen is the art of being at one with the two'ness
Go to Top of Page

membry
Junior Member

20 Posts

Posted - Sep 24 2009 :  3:15:29 PM  Show Profile  Reply with Quote
Our large legacy C++ is currently a mix of stage 2 and stage 3. Hench the request. Never thought of automating stage 1 to stage 2. Good idea. But many-to-one is a concern. Maybe just prepend the namespace and leave it to the user to remove the using namespace statement? We just used text search-and-replace, including some comments. Heh. But that was the quickest way to get around some include dependency problems and we were planning on getting rid of most using namespace statements anyway. Now we just manually convert from stage 2 to stage 3 as we refactor and it would be nice if VAX could help with that.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Oct 06 2009 :  6:59:26 PM  Show Profile  Reply with Quote
This makes sense, I have put in a feature request for this:

case=33328

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000