enums and constants patterns
There is a concept that is long praised in any code base I have seen: constants. They save so much value that almost everybody agrees that it is a must to define variables that hold a specific constant value. If, instead, we copied it to every single place where we need them, it would be much harder to update the value.
Some constants need to be flexible, hence, wise developers extract them to configuration files. Such files are stored in the code base, and sometimes in many different flavors (for instance, for test: dev, quality assurance, and production environments).
In many cases, the constants we define allow only a constant set of valid values. For instance, if we were to define available environments, then ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access