2 ms·
MISRA is sometimes unfairly shat on, sure, but some things do require you to use your brain. Regarding magic numbers, if my memory is not playing tricks on me,
by RealityVoid 3y ago
MISRA is sometimes unfairly shat on, sure, but some things do require you to use your brain.
Regarding magic numbers, if my memory is not playing tricks on me, MISRA does not include 0 or 1 as magic numbers. Regardless, 1 is 1 regardless the number system you work in, I have never ever seen someone "yes, let's make 1 not be 1" (not in a sane way at least) and defining stuff like that for "improved flexibility" is an antipattern in my book. It makes code bigger, harder to navigate and understand. That kind of code does unexpected stuff, is hard to work with and has more bugs. The less surprises, the less indirection I get in a code base, the better. I also feel it makes refactoring harder not easier. I speak from experience, I've worked with codebases like that, they suck. (Hello Vector, if anyone working for them is out there!)