5 ms·
One can call it BAD too, but I’ve done this several times: if (self-describing) { } else if (self-describing) { } else /* description */ { } and
by wruza 9y ago
One can call it BAD too, but I’ve done this several times:
if (self-describing) {
}
else if (self-describing) {
}
else /* description */ {
}
and
void myfunc(int a, char *b /* optional */, ...)
{
Block comments are not only block, but also inline. You cannot end line comment on the same line. (Though it is easy to work around).
As of good/bad: if you don’t like it personally, then don’t use it. If in group, then put that in group style guidelines, because these are required to read and follow anyway, for project to be consistent. To prove something is a bad idea in general is a hard work not worth doing.
- chrismorgan 9y agoPut the comments at the end of the line, introducing line breaks if necessary: if (…) { } else if (…) { } else { // description } and void myfunc(int a, char *b, // optional ...) I don’t program in C or C++, but when working with the Windows API I appreciate Microsoft’s source-code annotation language which leads to being able to indicate input and output parameters, and optional ones, so that you’d wind up with something like this: void myfunc(__in int a, __in_opt char *b, ...) I don’t know how they’re implemented in MSVC, but I’m guessing they’re just empty #defines.
- wruza 9y agoSure, I’m aware of these methods; these are obvious. But my preference is to put else-comment that way, because its beauty makes me peaceful and calm when I look at it. At work I’ll do what PM expects, i.e. her/his [motivated] preferences, not mine (if you ask people what they’d like to do, work will be hardly a popular option at all, so no problem, it is consensus between being “busy” and having profit).