Converting values to variables

One of the first and easiest things that can be done is to extract any hard-coded values to be represented by variables. Having a variable allows for a quicker and more consistent update. It also helps to convey intent.

When creating the variables, make sure the name is descriptive enough for the scope of the variable. Variables with a short scope can have a short name. On the other hand, variables with a long scope must have a longer, more descriptive name. The further a variable is from its usages, the more descriptive it needs to be so that the context it represents isn't lost.

Check the scope of your variables and make sure they do not have a larger scope than is necessary. Also, check for variables that should have a larger scope but are instead passed between private methods instead of being class members.

It is not recommended at this time to update the private and protected methods that depend on variables that could be moved to a class scope. Instead, make note of them and move them around after tests have been added.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.2.157