Cows Look Like Maps@sh.itjust.works to Programmer Humor@programming.dev · 7 months agoBill is a pro grammersh.itjust.worksimagemessage-square85fedilinkarrow-up1714arrow-down189
arrow-up1625arrow-down1imageBill is a pro grammersh.itjust.worksCows Look Like Maps@sh.itjust.works to Programmer Humor@programming.dev · 7 months agomessage-square85fedilink
minus-squaremagic_lobster_party@kbin.sociallinkfedilinkarrow-up11arrow-down1·edit-27 months 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-square18107@aussie.zonelinkfedilinkarrow-up7arrow-down1·7 months agoA better comment would be delay in seconds as that is the one thing not obvious from glancing at the code.
minus-squaremagic_lobster_party@kbin.sociallinkfedilinkarrow-up12·7 months 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.