重构整个项目的变量和参数名称 [英] Refactoring a whole project's variable and parameter names

查看:62
本文介绍了重构整个项目的变量和参数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个大型 C# 项目,其中所有变量和参数名称都是 written_like_this.

I have inherited a large C# project where all the variable and parameter names are written_like_this.

是否有一些简单的方法或工具可以让我在不超过 10 次鼠标点击的情况下自动重命名它们.这样上面的例子就会变成 writtenLikeThis (即骆驼案例).和实例变量_writtenLikeThis.

Is there some easy way or tool I could use to rename them all automatically with no more than say 10 mouse clicks. So that the above example would become writtenLikeThis (i.e. camel case). And instance variables _writtenLikeThis.

它还需要更新 XMLDoc 注释.

It would also need to update the XMLDoc comments as well.

我可能可以用正则表达式敲出一些东西,但前提是我不重写轮子.

I could probably knock something up with a Regex, but only if I'm not rewriting a wheel.

谢谢.

推荐答案

我同意 NewInTown 的观点,你应该保持原样,但是,如果你想改变名称,并且你有很好的单元测试,那么当您需要在函数中进行一些更改以修复错误,然后慢慢开始将名称更改为新方案.

I agree with NewInTown that you should just leave it as it is, but, if you want to change the names, and you have good unit tests, then when you need to make some change to fix a bug, in a function, then slowly begin changing the names to the new scheme.

这将防止您尝试将其自动化并创建许多新错误,并且您不会浪费时间对无法改进应用程序的工作代码进行更改.

This will prevent you from trying to automate it and creating many new bugs, and you won't be wasting time making changes to working code that doesn't improve the application.

我倾向于使用修复函数的时间来进行一些重构或基本优化,因为无论如何我都处于该函数中.

I tend to use time that I am fixing a function to do some refactoring or basic optimizations as I am in that function for some reason anyway.

这篇关于重构整个项目的变量和参数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆