Over a million developers have joined DZone.

Renaming Properties, Methods and Variables

· Agile Zone

Learn more about how DevOps teams must adopt a more agile development process, working in parallel instead of waiting on other teams to finish their components or for resources to become available, brought to you in partnership with CA Technologies.

Have you ever written some code and named something one thing only to realize that it should be named something else?

If you haven’t you haven’t been programming for very long.  Maybe you started a new job and you spent two weeks writing code using your previous employer’s naming conventions only to find out that this employer expects things to be named slightly differently.

So now you not only have the item named incorrectly, but you’ve referenced it from other files, so it isn’t a simple matter of just giving it a new name.  No, the code that is referencing it has to be changed as well.  So what are you going to do?

In the “old days” we’d change the name, recompile and fix all the references.  But now there is a much easier way to fix this problem.  All you need to do is to right-click on the property, method, or variable and select “Refactor” > “Rename…” from the context menu.

This will bring up a dialog box where you can give the item a new name and optionally select if you’d like to preview the changes, make changes in your comments (that are also referencing this variable name) and search for it in strings.

Press “OK” to continue and all of the names of the item as well as all of the references to that item will automatically be changed for you.

Discover the warning signs of DevOps Dysfunction and learn how to get back on the right track, brought to you in partnership with CA Technologies.


Published at DZone with permission of Dave Bush, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}