5 ms·
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
by srigi 4y ago
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
- wonderbore 4y agoBetter yet: const ONE_HOUR_IN_MS = 3600000 const RESEND_DELAY = ONE_HOUR_IN_MS
- mongol 4y agoI don't get why this is better. My approach: const RESEND_DELAY_MS = 3600000; // because TTL in Agora
- schobi 4y agoI would even go for const RESEND_DELAY_MS = 3600*1000; // because TTL in Agora Easier to check for the right number of zeros
- mongol 4y agoYes full agree
- sigg3 4y agoI've used stuff like this to do: const ONE_HOUR = 3600000; const RESEND_DELAY_MS = 2.5 * ONE_HOUR; // because TTL in Agora IMO it makes it easier for successor to fiddle with.
- tisc 4y agoI 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.
- kissgyorgy 4y agoI 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).