LouisIngenthron, (edited )
@LouisIngenthron@qoto.org avatar

question:

You need to replace references to the variable "terrainHeightValue" in your code with "terrainHeatValue". You know it's limited to one function, and there are 5-8 instances to be replaced.

What do you do?

PHolder,

@LouisIngenthron How about use the refactoring tools in your IDE?

LouisIngenthron,
@LouisIngenthron@qoto.org avatar

@PHolder Find & replace is much faster when you know the variable only exists in a limited section of text.

But also, I was limited to 4 options in the poll. 🤷‍♂️

PHolder,

@LouisIngenthron Ummm.. I guess you've never used Eclipse IDE. I highlight the "bad" variable name then I hit the refactor ➡ rename (there is a keypress for it, I just don't use it) and then overtype the new name and press enter. It finds ALL the correct places (cause it understands the code) and just does the necessary replacement. Quick/easy/painless.. it knows how to do it better than I would in the sense it won't accidentally miss any occurrences I might.

LouisIngenthron,
@LouisIngenthron@qoto.org avatar

@PHolder Same works with Visual Studio, and it works fine in smaller codebases, but in larger ones, it can take a few seconds to check every file for references.

With find & replace, otoh, I can highlight the variable name, press Ctrl+H and it prefills the "to replace" field and puts my cursor on the "replace with" field. Type it in and press enter and it's done, with no delay and only one mouse click.

positroni,
@positroni@mastodon.social avatar

@LouisIngenthron Refactor -> Rename automated IDE action. In case the rename does not succeed because it complains that the name is already in use it is possible to change the existing variable name manually to something placeholder and then rename.

LouisIngenthron,
@LouisIngenthron@qoto.org avatar

@positroni In big code bases, that can cause quite a delay, though. I usually reserve it for variables I know are used in multiple files.

That said, if I could have included more than 4 options, I would have added it.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • ComputerScience
  • rosin
  • Durango
  • thenastyranch
  • ngwrru68w68
  • InstantRegret
  • DreamBathrooms
  • modclub
  • magazineikmin
  • Youngstown
  • everett
  • ethstaker
  • slotface
  • mdbf
  • kavyap
  • JUstTest
  • osvaldo12
  • GTA5RPClips
  • cisconetworking
  • provamag3
  • khanakhh
  • tacticalgear
  • cubers
  • Leos
  • normalnudes
  • megavids
  • tester
  • anitta
  • lostlight
  • All magazines