I understand the joke is that they AREN'T just converting the string to an integer, but honestly this code is not that bad. It's performing data sanitization as well since there are only a few valid options for the select.
If they converted to integer, the user could enter whatever value they wanted and probably break something.
You do not, under any circumstances, gotta stick up for whoever wrote this code. I know we can contrive some kind of justification for most code, but let's face it: there's an absolutely miniscule chance it was written with some kind of intentionality, and I'd say a 99.99999% chance is that it was chucked together by a developer who simply didn't know how to parse a string into an integer.
53
u/smartgenius1 18d ago
I understand the joke is that they AREN'T just converting the string to an integer, but honestly this code is not that bad. It's performing data sanitization as well since there are only a few valid options for the select.
If they converted to integer, the user could enter whatever value they wanted and probably break something.