3 ms·
>> Comments, by their nature, are static. Says who? Comments, like unit tests, and READMEs, need just as much attention as raw app code. As others have said he
by ceautery 10y ago
>> Comments, by their nature, are static.
Says who? Comments, like unit tests, and READMEs, need just as much attention as raw app code. As others have said here, explaining what the code is doing isn't the end goal of comments, because you can read the code for that.
I tend to use comments mainly for handoff purposes. One of my peers needs to know what I was thinking, goals, anomalies, etc., rather than how to parse syntax, which they can do already. Here's a random example:
/*
* checkReady() starts the winston logger, which is set to catch unhandled exceptions. We don't want
* to do that until both the web and SMTP listeners have started, so that they can throw errors and
* exit the app. This is important because running on well-known ports without cap_net_bind_service
* shouldn't fail silently.
*/
function checkReady() {
if (++serverCount == 2) startLogger();
}
...And whether or not I've made a bad decision here regarding startup logic is moot. :)