Refactoring is the process of cleaning up code or changing a design using a sequence of very small steps. No new functionality is added or removed during the refactoring process. The aim of refactoring is to make the code better by eliminating some code smell. There are many types of refactoring, from the extremely simple going up to much more complex refactorings. Let us apply some of these to the code above.
These two are probably the two simplest refactorings. The names are self explanatory—the refactoring is to rename a variable or a method. Although simple, they are very important because poor variable and method names are very common code smells.
The following are the steps to apply the Rename Variable refactoring:
Run all the tests to make sure they are passing.
Change the name of the variable, and make the change in all the places where it is being used.
Run all the tests again to make sure we didn't break anything.