There always comes a time when we just need to use a single number or set of numbers in our code…. but please avoid typing something like:
Instantly I thinking
What is 3?
Is there a 1 and 2?
Is there documentation somewhere that can help?”
You can add a comment, that would be a bit helpful. But I believe a better solution is either an Enum or Class of constants. These solutions make your code more readable, and give more context around what “3” is.
Enum:Class of Constants:
Obviously these aren’t the only solutions… simply making a variable with a descriptive name might be enough…. but DO NOT just type a constant in the middle of your code.