b) I didn't give enough context for your specific commentary to really make sense. I mean, when did I even say this is a function? It's a snippet of pseudo-code not a code sample.
c) Are you really running around programs ripping out references because you don't know what they do? I'd advise working on your definition of optimization before worrying about whether your code documents itself.
Agree. I assumed you were giving an example of self documenting code that doesn't require comments.
>I didn't give enough context for your specific commentary to really make sense. I mean, when did I even say this is a function? It's a snippet of pseudo-code not a code sample.
Yes, sorry. I've just spend the last month digging into shitty code, so I'm in dealing with shitty code mode. My point was the name you gave it didn't give any intent as to why the application would be napping, which is probably the most important information. Of course, as you said, the owner function could be named properly in that way.
>Are you really running around programs ripping out references because you don't know what they do? I'd advise working on your definition of optimization before worrying about whether your code documents itself.
It's pretty common for developers to try to figure out why an application is running slow. If I saw that (sleep function), it would be an obvious sign of why it's slow. If I saw that I would immediately see it as a potential target of improvement. Unfortunately with just the label you provided and a poorly named owning function, I wouldn't have enough information to determine if it was removable because, again, I don't know why it is napping. I would then have to spend several minutes/hours/days ($$$) determine what the hell that nap was for. This could all be solved by a comment providing intent.
I would suggest instead of NAP_LENGTH_MINUTES, it would be NAP_TO_AVOID_PROCESS_COLLISION_LENGTH_MINUTES or something. Of course, naming things properly is one of the hardest things in computer science. :)
There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton