Safest way to change variable names in a project

喜夏-厌秋 提交于 2019-12-05 06:23:42

Safest (non automated way) way:

  1. Make sure all your unit tests work.
  2. Save everything into source control.
  3. Globally replace var with XXXvarXXX (seriously)
    a. Or maybe just the files you think need editing.
  4. Try and compile. Everything that does not compile is easy to undo just remove the XXX.
  5. When it compiles run the unit tests.
  6. When the unit tests work. Do a global replace of XXXvarXXX to the new name.
  7. Make sure the unit tests still work
  8. Save everything in source control.

Tongue only half in cheek. :-)

It's called refactoring, but I don't remember if there's a great way to do it in C++ -- I think maybe Eclipse C++ had it; might be worth taking a look.

I remember visual stuio being able to do this, but what's the safest and most elegant way to do this on linux?

You can do pretty much what you used to do in visual studio in Eclipse using the re-factoring tools, which is available for Linux.

$400 a f'n copy, but here you go: http://www.xref.sk/xrefactory/download.html

I've of course never used it.

I know C# and visual studio has a great variable changer, but does it work through all the documents im not sure. I know when you change a variable in C# it pops up in the beside the Variable text. Change All

However you may be stuck with the only option. Change variables and see where the compiler goes wrong. However its not ideal, but may be your only choice

use private variables, rename the variable and the obvious uses, correct the compiler errors.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!