20.1k views
0 votes
Explain why each of the following names does or does not seem like a good variable name to represent a state sales tax rate.

a. stateTaxRate

b. txRt

c. t

d. stateSalesTaxRateValue

e. state tax rate

f. taxRate

g. 1TaxRate

h. moneyCharged

1 Answer

4 votes

a. stateTaxRate - A good variable name because it represents what it holds, the state sales tax rate, without being too wordy. Also correctly capitalized in camelcase.

b. txRt - A bad variable name because while short and simple, it is too hard to understand what the variable represents.

c. t - A very bad variable name if you plan on using the variable often. Far too short and you will forget what it represents and is needed for.

d. stateSalesTaxRateValue - A bad variable name because it is just too wordy. Cutting it down to A's variable name is much more reasonable

e. state tax rate - A bad variable name and probably invalid because it has spaces in the name.

f. taxRate - A good variable name if there are no other tax calculations other than state tax rate. Otherwise you would confuse state vs local tax rate or something, making it a bad variable name.

g. 1TaxRate - A bad variable name because the number 1 has no reason being in the variable name. It doesn't add anything to the name.

h. moneyCharged - A bad variable name because it is not specific enough in explaining why the money is being charged and what for.

User Technerd
by
6.4k points