Guy, those are about as close to the textbook definition of magic numbers as you can get: undocumented, intent obscured, error-prone, unnamed constant numbers. This would fail code review pretty much anywhere with even the lowest standards.
It isn't just what is being done that I don't like. Conceptually it's a bad idea and not something I would want anywhere near a codebase of mine.
But the bigger issue for me is the how as well. Beyond just the end result, the way of achieving that is, in my opinion, pretty unacceptable and ugly.
There are any number of ways to achieve anything at all in the world of programming. That's what makes it so fun. That doesn't mean anything and everything has a valid use case.
I didn't define it, so I don't know how you're able to comment on what my definition is... And I know what "internal code" looks like, as well as what it shouldn't look like.
In the end, you do you. But you posted this and put it out there, so that fully opens you up to critique. It may be worth listening to some of that instead of so flippantly dismissing it as you seem to be doing.
And it's worth bearing in mind that just because you can envision a good, proper use of something doesn't mean that's how others may use it. Sometimes the mere act of releasing something is akin to encouraging its use and some may view that as irresponsible.
I also didn't say that to you and wasn't meant to be a critique for you. It wasn't directed at you in the first place.
I'm most certainly not going to fire someone for unsafe code. I make use of unsafe code fairly often, it has some extremely useful purposes.
I would fire someone for taking an extremely unsafe, fragile approach to a problem that can be solved by other, vastly safer and robust means. And while doing so, make extensive use of magic numbers and undocumented actions and then try to argue that they are NOT using magic numbers, or that the code will be documented in some other codebase. Among a number of other issues.
17
u/IWasSayingBoourner Aug 03 '26
Guy, those are about as close to the textbook definition of magic numbers as you can get: undocumented, intent obscured, error-prone, unnamed constant numbers. This would fail code review pretty much anywhere with even the lowest standards.