Cows Look Like Maps to Programmer [email protected] • 1 year agoBill is a pro grammersh.itjust.worksmessage-square84fedilinkarrow-up1786
arrow-up1785imageBill is a pro grammersh.itjust.worksCows Look Like Maps to Programmer [email protected] • 1 year agomessage-square84fedilink
minus-squaremagic_lobster_partylinkfedilink12•edit-21 year agoI’ve seen code that look like this: int delay = 15 * 60; // 10 minutes Even if the comment was on the same line someone forgot to update it. People just ignore comments. Better solution is to write (in C#): TimeSpan delay = TimeSpan.FromMinutes(15) Much more obvious what the code actually means.
minus-square@[email protected]linkfedilink8•1 year agoA better comment would be delay in seconds as that is the one thing not obvious from glancing at the code.
minus-squaremagic_lobster_partylinkfedilink13•1 year agoOr just name the variable delaySeconds if you really want to store it as an int. Bonus is that every use of the variable perfectly communicates what it is.
I’ve seen code that look like this:
int delay = 15 * 60; // 10 minutes
Even if the comment was on the same line someone forgot to update it. People just ignore comments.
Better solution is to write (in C#):
TimeSpan delay = TimeSpan.FromMinutes(15)
Much more obvious what the code actually means.
A better comment would be
delay in seconds
as that is the one thing not obvious from glancing at the code.Or just name the variable
delaySeconds
if you really want to store it as an int. Bonus is that every use of the variable perfectly communicates what it is.