Рет қаралды 38
There are often times that we need certain values in our code, like some string value to properly retrieve a value from a data set, a limit for some threshold or the URL of a server to query.
When the value is put directly into the code, it can be hard to understand what that particular value was chosen, it tends to be lacking context around it’s meaning. And thus it becomes a magic value.
Today I’ll talk about this, and how we can improve readability by moving these magic values into constants.
While all my examples today are in Python, this idea applies to most programming languages.