4 ms·
It's "obvious" if you take into account the corporate culture I guess. The rule of 'no magic numbers' is generally good, but then one has to remember that some
by yoz-y 6y ago
It's "obvious" if you take into account the corporate culture I guess. The rule of 'no magic numbers' is generally good, but then one has to remember that some numbers (like 0 and 1) are not magic.
- loa_in_ 6y ago0 and 1 can be magic if the context depends on them being arbitrarily 0 or 1. eg. // this byte is unused and always 0 #define UNUSED_CONSTANT_FIELD_VALUE 0 bytes = {HEADER, UNUSED_CONSTANT_FIELD_VALUE, [...]}
- cratermoon 6y agoLet me tell you about the system where null and 0 are treated as equal because in some programming languages will coerce null to 0. It just so happens that for an important business type in this system: the range of the type is the non-negative integers up to (2^32)-1 semantically, the value cannot be null when the value is 0, the code treats it as a special case null is treated as 0