Does it make sense to create a constant for the value of a penny? For example, if I needed to decrement an amount by a penny. Do you think it is more readable if the code said:
amount -= Constants.StandardAmounts.Penny
Or should I not even bother and just use .01.
In your specific example, that particular constant does not really make sense. The two likeliest scenarios to subtract a penny are:
Fulfill some very specific business/domain logic requirement:
If so, the constant should not be
Penny = .01, butStandardDeduction = .01Handle more arbitrary/fluid maths:
If so, just use numbers.
In either case, “Penny” is pointless. It does not add any useful information. That’s like declaring
constant HelloWorld = "HelloWorld". Every programmer who has even a vague idea of what your application is doing (financial calculations) understands what .01 is. Constants should be driven by purpose.