Asked a colleague in code review to extract magic numbers and got told “devs should know”

Posted by Evening_Speech_7710@reddit | ExperiencedDevs | View on Reddit | 542 comments

Had a slightly frustrating code review interaction and I’m curious how others would handle it and if I’m overthinking this or not?

The colleague submitted a PR with logic like:

> if abs(lat) > 180 { ... }

and similar checks using 90 and 180 regarding coordinates.

I asked what those numbers meant and asked if he could extract them into a constants enum so the intent is clearer:

> if abs(lat) > Constants.maxLatitude { ... }

My thinking was just readability and maintainability, so it’s more obvious what the condition actually means instead of assuming knowledge.

They replied saying there is “no value in adding this” and that it adds unnecessary complexity and that devs should already know this.

I replied explained my reasoning like self-documenting, thinking for future devs, less cognitive load etc… with examples on how it would look like.

They did add the constants, but with a comment along the lines of:

> “Nice usage of ChatGPT :)) I still don’t see the value. Plus latitude and longitude is something we learn in school but yes in case anyone missed it I will add it in.”

I found that pretty annoying tbh. Not even about the constants, more that he just dismissed what I was telling them.

Was I being too pushy for something was fairly nit picky maybe? Thoughts?