Re:When hiring developers, have the candidate read existing ...
by srigi on Saturday April 16, 2022 @02:04AM
(#31049946)
Agree. I also add to this - name your constants by meaning, not value. Too many times I see
const ONE_HOUR_IN_MS = 3600000
Instead I would like to see const RESEND_DELAY = 3600000
Re:When hiring developers, have the candidate read existing ...
by tisc on Saturday April 16, 2022 @02:30AM
(#31050085)
I like to combine those:
const RESEND_DELAY_MS = ONE_HOUR_IN_MS;
Having the unit in the name saved me more than once and having non-contextual constants for sizes increases readability imo.
Re:When hiring developers, have the candidate read existing ...
by kissgyorgy on Saturday April 16, 2022 @03:08AM
(#31050267)
I do this instead:
const RESEND_DELAY_MS = 1 * 60 * 60 * 1000; // one hour
Essentially the same, but the lack of extra variable spares one jump. Also you can change it without introducing a new variable (no dependency).
Re:When hiring developers, have the candidate read existing ...
by wonderbore on Saturday April 16, 2022 @02:26AM
(#31050068)
Better yet:
const ONE_HOUR_IN_MS = 3600000
const RESEND_DELAY = ONE_HOUR_IN_MS
Re:When hiring developers, have the candidate read existing ...
by mongol on Saturday April 16, 2022 @02:46AM
(#31050166)
I don't get why this is better. My approach:
const RESEND_DELAY_MS = 3600000; // because TTL in Agora
Re:When hiring developers, have the candidate read existing ...
by schobi on Saturday April 16, 2022 @03:08AM
(#31050266)
I would even go for
const RESEND_DELAY_MS = 3600*1000; // because TTL in Agora
Easier to check for the right number of zeros
Re:When hiring developers, have the candidate read existing ...
by mongol on Saturday April 16, 2022 @03:23AM
(#31050358)
Yes full agree
Better yet, turn magic numbers into constant variables whose name becomes the comment. Of course, comments can also provide additional context :)