0

When programming in C#/Java, I have been often using refactoring like Extract method to make code more readable. I am working on a C++ project now, and due to the absence of IDE support for this type of refactoring (I use Visual Studio 2015), it is quite annoying to manually type all those helper function declarations into header files.

I found a potential solution for that - anonymous namespaces. One challenge may be due to the fact that I would have to pass all class members to functions defined in anonymous namespaces (or pass this as a parameter to those functions).

I want to understand if I am not using the feature of a language (anonymous namespaces) in a wrong way. Is there any potential problem with the above approach that I am not aware of?

oldbam
  • 2,397
  • 1
  • 16
  • 24
  • Can you show an example of code you have and how you want it to be refactored? – NathanOliver Mar 03 '17 at 12:44
  • Potential example: https://sourcemaking.com/refactoring/extract-method – oldbam Mar 03 '17 at 12:49
  • Not sure if the printing refactoring works here. Generally in C++ you would overload the `operator <<` to output an object. Then you only output the object state with that and if you want to add anything else you would do that yourself in same output chain. Do you use it for other functions? – NathanOliver Mar 03 '17 at 12:52
  • use CLion. It's the best IDE for c++ bar none. – Richard Hodges Mar 03 '17 at 13:08

0 Answers0