Is renaming variables a type of refactoring, or is refactoring something different? In other words, what's the difference between renaming and refactoring? I thought they were the same thing.

"Code refactoring" mentions renaming only here:

Rename method or rename field – changing the name into a new one that better reveals its purpose

But it doesn't mention renaming variables.

| improve this question | | | | |
  • 3
    Hello Geremia, askers on this site are expected to do some research before they ask. Unfortunetale, the question in the current state gives the impression of absolutely zero research effort, but maybe you did some and just forgot to mention? So please tell us what you found and why it did not suit your needs, then we can probably give you a better answer. – Doc Brown Nov 19 '18 at 19:43
  • 1
    The difference between renaming and refactoring is the same as the difference between a green Toyota Corolla and a vehicle. – Jörg W Mittag Nov 19 '18 at 20:33

Renaming variables, functions, classes is in fact a type of refactoring (one of the simpler types). Renaming was cataloged as a type of refactoring in the classical text on refactoring by Martin Fowler.

Definition of refactoring:

Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure. [Martin Fowler]

Different kinds of refactoring fit this definition: from small and trivial ones which could take 5 minutes to large refactorings which take months.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.