void new_function(int a) ---> void newFunction(int a)

Status
Not open for further replies.

technophile

Ars Legatus Legionis
23,768
THBMan":3pteeask said:
I'd be concerned about doing a simple search and replace clobbering things other than just function names. At least more paranoid that the people saying it would only take a few minutes.
This is why automatic refactorings that actually understand the code make IDEs so much more powerful than a text editor. In my preferred I can perform this kind of rename nearly instantly while automatically fixing up all references[1] across my entire codebase *and* be warned if I'm causing a name collision or other problems at the same time.

[1] Well, mostly. Renaming a method/class that gets exposed to/as a JSON web service pretty much sucks all the time. :p
 

Richard Berg

Ars Legatus Legionis
43,037
Subscriptor
If human-readable history is your concern, why not strip out the rename entirely? Here's a simple algorithm:

Code:
ViewDiff( Left = CompareFromRevision, 
          Right = ComputeMerge( Base = RefactorRevision, Left = RefactorRevision - 1, Right = CompareToRevision ) 
        );

Same strategy can be adapted to arbitrarily complex scenarios. That's why we have version control, after all. We recognize that tools are better at this stuff than humans are, so we preserve all the metadata a future tool might need. Use it!
 

MilleniX

Ars Tribunus Angusticlavius
8,139
Subscriptor++
a7244270":ubcem2d1 said:
Create a wrapper that converts calls to this_function to thisFunction. Old code is untouched, so you don't have the problem of a zillion diffs making life shitty. New code is written calling functions that aren't named the way you don't like them named.
This is a bad idea for a few reasons. First of all, it adds more code for a later developer (including yourself 6 months from now) to read and understand. That developer will always have to look at the ostensible wrapper, and make sure that it really is just a wrapper. Second, an incautious developer (which again, is nearly everyone, when asked to make a rushed bugfix) might add code in the wrapper instead of the wrappee, meaning some callers will have the bugfix and others won't. Third, not all languages support perfect forwarding (C++ doesn't, yet), so the wrapper can have effects on visible behavior as well as the nominally marginal (but potentially disastrous, in the presence of copy constructors, network connection objects, etc) effect on performance.
 
Status
Not open for further replies.