Re:Reducing technical debt by valuing comments as much as code
by andreareina on Wednesday February 01, 2023 @01:53AM
(#34607331)
I’m a fan of comments, but in this case I would reach for an enum with descriptively-named members, e.g. HTTPStatus.TOO_MANY_REQUESTS
[ Parent
| on HN ]
Re:Reducing technical debt by valuing comments as much as code
by helmholtz on Wednesday February 01, 2023 @02:14AM
(#34607456)
Making it strictly worse. TOO_MANY_REQUESTS? How many is too much? In what scenarios?
The code comment in the GP is pithy, explanatory, and reads in plain English. Yours is ripe for misunderstanding.
Re:Reducing technical debt by valuing comments as much as code
by andreareina on Wednesday February 01, 2023 @11:27AM
(#34612845)
My bad for not being clear, I was really talking about the comment saying 429 means “too many requests”. By all means comment to say that service X has a rate limit of N req/min but a comment saying 429 means too many requests is exactly one of those things that’s better expressed in an enum.
301; 302; 401; 429; 504; I shouldn’t need comments to tell me what they are, nor should it be expected that anyone touching the code knows them off the top of their head.