Why do I see XXX in comments
From AJS.COM
Why do I see XXX in comments? This is a fairly common question that I hear from programmers who either haven't worked on other people's code much, or who are just starting out, so I thought I should answer.
When you see something like this (this example is C++, but this isn't a language-specific thing, and you'll see such comments in Perl, Python, C, C++, Java, Ruby, JavaScript, etc.):
// XXX edge case: account for y==NULL y=do_something();
The XXX is there to tell those looking at the code that the original programmer felt there was a flaw, limitation or work to be done there.
Contents |
So is this bad?
It really depends. It's certainly code that you should look at carefully, but sometimes it's just a programmer making a note to themselves. Use your own judgment, as there's no strict conventions, here.
Why not use assertions?
Most languages support some form of assertions, so why not use those instead? There are several reasons. First off, that might not be the right solution. Sometimes having the program fail is exactly the wrong thing to do. Sometimes these notes are just indications of future work to be done, e.g.:
create_database_table("foo");
# XXX - and someday, we'll also create bar:
# create_database_table("bar");
There's no assertion to make, here, it's just a placeholder for future work.
Is this the sign of a bad programmer?
I've had to support a lot of other people's code, and I have to say that I'd rather see some foresight into potential pitfalls and shortcomings than get the sense that the original author had no idea what was going on.
Why XXX
The real reason is lost to history, as far as I know, but the reason that it stuck is pretty clear: XXX is fairly short and easy to type, but is unlikely to occur normally in your code unless you write software for those sorts of Web sites. This makes it very easy to search for such comments using your editor of choice or from the command-line.
