Hacker News new | past | comments | ask | show | jobs | submit login

That person might just be a regular Java developer who works on a project which onboarded Checkstyle, and can't disable it's MagicNumber check.

https://checkstyle.sourceforge.io/checks/coding/magicnumber....




Man, I hate such tools. Do I run into problems when I try to convert seconds to minutes?

Larger problem than magic numbers ever could be.


Yes! Anytime you see a function signature like "int timeout", it's safe to assume that the unit is in femtoseconds and pass a gigantic number while you curse out the incompetence of the developer. Either name your variables correctly (timeoutZeptoseconds), or use a proper data type (like a Duration or Period in Java, TimeSpan in C#, or a user-defined literal in C++).


Oh, now I get why you need those constants:

  var secondsPerWeek = Math.pow(2, SEVEN) * Math.pow(THREE, THREE) * Math.pow(FIVE, 2) * SEVEN




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: