"// ..." comments at end of code block after } - good or bad?
- by gablin
I've often seen such comments be used:
function foo() {
...
} // foo
while (...) {
...
} // while
if (...) {
...
} // if
and sometimes even as far as
if (condition) {
...
} // if (condition)
I've never understood this practice and thus never applied it. If your code is so long that you need to know what this ending } is then perhaps you should consider splitting it up into separate functions. Also, most developers tools are able to jump to the matching bracket. And finally the last is, for me, a clear violation to the DRY principle; if you change the condition you would have to remember to change the comment as well (or else it could get messy for the maintainer, or even for you).
So why do people use this? Should we use it, or is it bad practice?