There are only two hard things in Computer Science: cache invalidation and naming things.
— Phil Karlton
How many VBA modules declare variables looking like this:
Dim v As Long, vWSs As Variant, Mrange As Range, Vrange As Range
Or like this:
Dim i As Long Dim LR As Long
How many procedures have cryptic names that only the author knows what they mean?
How many Times did you refrain from renaming a procedure in fear of breaking the code?
Fear no more. Renaming doesn’t have to be the hardest part of using meaningful names in code.
With the next release of Rubberduck, finding a meaningful name is going to be the hardest part – I’m please to announce that Rubberduck 1.3 will feature a rename refactoring:
Awesome. How does it work?
I’m tempted to say “Magic!” here. Rubberduck uses the current selection (/caret location) to guess what you’re trying to rename. If you’re on a constant usage, it knows to rename the constant and every single one of its references; if you’re just inside a procedure scope, it guesses you want to rename the procedure and affect every single call site; if you’re somewhere in the declarations section of a module, it lets you rename the module itself, and automatically adjusts every explicit reference to it.
The Rubberduck/Refactor menu will feature a new “Rename” button, accessible with Alt+B,R,R (Rubberduck/Refactor/Rename).
The Code Explorer‘s context menu will also feature a “Rename” button, so that any module/member can be renamed without even looking at the actual code.
Lastly, we’ll hijack the code pane context menu and add our “Refactor” menu in there, too.
Naming is hard. Renaming doesn’t have to be!