78

What do people generally mean whenever you see XXX in a comment. Occasionally, I'll see a comment like this:

# XXX - This widget really should frobulate the whatsit

Of course, I can tell what the comment means, but what does the XXX generally mean? Is it saying "This is a hack" or maybe "Perhaps we should revisit this later"? Or is it saying something else entirely?

jdl
  • 629
  • 3
  • 9
Jason Baker
  • 9,625
  • 8
  • 44
  • 67
  • 3
    There are plenty of references by which to answer this question: http://www.catb.org/jargon/html/X/XXX.html ; http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-137265.html#395 ; http://c2.com/cgi/wiki?FixmeComment – pkh Sep 19 '14 at 16:54
  • I use `qaz` personally. Easy to type and in 40 years of coding it has never occurred naturally in my code, so I can easily search for it. Rather than FixMe: or ToDo: I use it for quick experimental hacks which I can then easily reverse if they don't work out. But my `qaz` would **never** be committed to source control, whereas FixMe: or ToDo: or XXX could be. – Mawg says reinstate Monica Mar 30 '16 at 14:54
  • I've noticed that there are a lot of old XXX comments in Meteor's codebase...kind of a running commentary on its dirty secrets. And it seems like they use some tool to automatically strip them out from the code that gets shipped! – Andy Apr 01 '17 at 16:13

9 Answers9

102

It's a dirty piece of code ;)

MattyD
  • 2,285
  • 1
  • 17
  • 18
77

What XXX represents, depends on the author of the code. In general, it is used as a marker for code that requires attention.

However, this web page states a somewhat different train of thought:

XXX : used to flag something that is bogus but works

FIXME : used to flag something that is bogus and broken

I guess this further shows that its meaning is not well defined and is used differently.

kostmo
  • 103
  • 3
J.K.
  • 13,063
  • 1
  • 40
  • 56
23

Per Wikipedia: "XXX to warn other programmers of problematic or misguiding code." -- which might be pulled from containers of poison that say "xxx" on them; super old school.

If it's a TODO note, here's a related blog post on it called, TODO or not TODO, which covers using GREP to sort comments by date, owner, etc.

blunders
  • 4,550
  • 4
  • 31
  • 48
13

It means nothing. It's just a sequence of characters that is visually distinctive (which makes it easy to scan for visually) and unlikely to appear in either code or comments (which makes it easy to search for programatically).

So, it is used as a marker to flag comments that need to be easily searchable. Usually, it marks a piece of code that needs to be revisited.

Miles Rout
  • 919
  • 7
  • 11
Jörg W Mittag
  • 101,921
  • 24
  • 218
  • 318
7

IIRC it is an annotation that predates and has similar meaning to TODO or FIXME annotations. It's quite common in vim's source, for instance.

gablin
  • 17,377
  • 22
  • 89
  • 138
Rein Henrichs
  • 13,112
  • 42
  • 66
6

It is most likely a character sequence which does not occur in regular code, meaning that it is easily searchable from a command line:

ravn:tmp ravn$ echo XXXX This is very bad > processor.c
ravn:tmp ravn$ echo XXXX Verify defaults before going in production > main.c
ravn:tmp ravn$ grep -R XXXX .
./main.c:XXXX Verify defaults before going in production
./processor.c:XXXX This is very bad
ravn:tmp ravn$ 

(example is for Unix, I believe "findstr" does the same under Microsoft Windows)

4

but what does the XXX generally mean? Is it saying "This is a hack" or maybe "Perhaps we should revisit this later"? Or is it saying something else entirely?

Any of the above.

The choice of XXX versus TODO or FIXME or HACK or something else is not governed by any strong rules or conventions. Basically, it means whatever the person who put it there intended it to mean. It may be obvious ... or it may be totally opaque to you.


UPDATE Wikipedia currently (2016-03-30) says:

Such tags differ widely, but might include:

  • ...
  • XXX - warn other programmers of problematic or misguiding code

Note the clear caveats in the original text. The XXX could be construed as an allusion to the "XXX" that you see on poison and/or moonshine bottles in classic comics, cartoons, etc.

Stephen C
  • 25,180
  • 6
  • 64
  • 87
2

It is most probably a marker that can later be found. Unlike TODO or FIXME or the alike, XXX is very rarely found in any word or construct, therefore making it perfect for a marker that will stand alone when files are being searched through.

Rook
  • 19,861
  • 9
  • 53
  • 96
0

Where I am originally from we use XXX (and then YYY, ZZZ) for numbers that we do not know them yet, for example: add XXX to YYY to find the result, then add 10%.

Originates from equations at school where 'x' is the unknown variable.

Dimitrios Mistriotis
  • 2,220
  • 1
  • 16
  • 26