concept variable in category software development

This is an excerpt from Manning's book Five Lines of Code.
After concluding our work with
draw, we continue with another example — theupdatemethod — and repeat the process, refining how we work with the code without diving into the details of it. This example teaches us to identify a different symptom that a method is doing too much; and through Extract method [P3.2.1], we learn how to improve readability by renaming variables.
Move the variables into the new class, replacing letwithprivate. Simplify the variables' names; also make getters and setters for the variables.
Because the variables are no longer in the global scope, the compiler helps us find all the references by giving errors. Fix these errors in the following five steps:
- Pick a good variable name for an instance of the new class.
- Replace access with getters or setters on the pretend variable.
- If we have errors in two or more different methods, add a parameter with the variable name from earlier as the first parameter, and put the same variable as the first argument at call sites.
- Repeat until only one method errors.
- If we encapsulated variables, instantiate the new class at the point where the variables were declared. Otherwise, put the instantiation in the method that errors.
Because the variables are no longer in the global scope, the compiler helps us find all the references by giving errors. Fix these errors in the following five steps:
Move the variables into the new class, replacing
letwithprivate. Simplify the variables' names; also make getters and setters for the variables.
Listing 6.58. Before
let counter = 0; class Counter { }Listing 6.59. After (1/4)
class Counter { private counter = 0; #1 getCounter() { return this.counter; } #2 setCounter(c: number) { this.counter = c; } #3 }Move the variables into the new class, replacing
letwithprivate. Simplify the variables' names; also make getters and setters for the variables.