I don’t fully agree this is bad code. This depends a lot on the context like:
is there a company rule that requires every assignment to be documented (in which case the rule itself is the “problem”, not the code)
the name magic number might be very meaningful to everyone working on this project or even the whole industry (I’m not a game dev so I don’t know but I’ve seen the term magic number in other software where people were aware of its meaning)
The actual term for this value is "magic number". This is the correct name for this variable. Clear, concise naming does not include defining terms in the definition name for readers ignorant to the problem domain.
Edit: Just to clarify, I mean ignorant in the neutral sense, not the hostile form as an insult.
119
u/[deleted] Jun 09 '20
I don’t fully agree this is bad code. This depends a lot on the context like:
is there a company rule that requires every assignment to be documented (in which case the rule itself is the “problem”, not the code)
the name magic number might be very meaningful to everyone working on this project or even the whole industry (I’m not a game dev so I don’t know but I’ve seen the term magic number in other software where people were aware of its meaning)