10

I'm doing the same. When there is something "to-do" in my code, I write //TODO .... But I'm curious to know when this started and if there is a reason for writing "to-dos" in all capital letters?

6
  • 21
    Because we really MEAN IT (we just never actually get around to it) Commented Dec 23, 2011 at 23:16
  • 3
    so editors can mark them and let you search through them (eclipse's task list for example) Commented Dec 24, 2011 at 0:54
  • 6
    Since you couldn't actually make text bold inside the code you needed some way to make important things stand out. Hence... Commented Dec 24, 2011 at 3:44
  • 4
    Why does it matter? Commented Dec 24, 2011 at 3:59
  • 3
    I write //todo:... Commented Dec 24, 2011 at 13:18

8 Answers 8

24

Also, it's great to have a way to easily search for code sections you glossed over and want to get back to. You can do a case-sensitive search for "TODO" to immediately find what you skipped before.

"todo" (lower-case) could potentially be part of a larger word/function/variable, but "TODO" (upper-case) is probably not going to be.

6
  • 4
    It also allows editors to highlight this. gedit does it, for instance, and it only does it for all upper-case TODO. Whatever the reason, it's enough incentive for me to write it in upper case. Commented Dec 23, 2011 at 23:49
  • 4
    @delnan: That's a tautology. It was done to stick out, so people used it, so somebody added the syntax highlighting in vim to stand out more, so people use it to stand out. People don't use it because the editor makes it stand out they use it because it is common to do so and thus the editor makes it stand out. You can make anything stand out in vim just change the syntax highlighting appropriately it is just as easy to make todo stand out but there is little point in that as the convention is to use TODO. Commented Dec 25, 2011 at 9:06
  • 1
    @LokiAstari: As I said, I for one spell it in capitals because more editors highlight that by default. But perhaps I'm an exception: Quite young (so I couldn't have done it before editors supported it) and (sadly) too much of a whimp and lazy bum to adjust syntax highlighting manually. Commented Dec 25, 2011 at 9:43
  • Also nice for the poor guy who needs to clean up after you, and for anyone who needs to look over your code before it's complete. They can see at a glance what's not yet done because of this convention. Commented Dec 25, 2011 at 12:25
  • 2
    I have encountered mixed-case TODO within a variable name like filesToDownload. Of course, "whole words only" search fixes that problem. Commented Jan 20, 2012 at 3:25
9

I'm curios to know when this started and if there is a reason for writing to-dos all capital?

The idea with comments like TODO and FIXME is to make them stick out. You generally don't want to ship code that has such markers in the code -- they mark things to be done before the project can be considered complete. Using ALL CAPS makes them a little easier to spot, provided you don't use ALL CAPS for a lot of other things in your code too.

5

I just stands out and is easy to catch... nothing complicated!

2
  • 1
    that and its easy to find via grep or the like Commented Jan 20, 2012 at 7:43
  • @ZacharyK: Exactly! Commented Mar 3, 2012 at 20:35
5

Both Eclipse and Visual Studio have Task List features that automatically give you lists of comment lines that have TODO in them.

2
  • Visual Studio started doing the // TODO: comments when it first added the code generators for MFC boilerplate stuff. That was version 2.0, iirc. Commented Dec 24, 2011 at 5:05
  • at least for Visual studio this search is not case sensitive - it will pull //todo foo into the task list too Commented Jun 11, 2012 at 13:39
2

Some editors only highlight uppercase TODO items, so it's safer to always use uppercase.

1

It calls attention to the fact that there exists a todo.

It is important that it be obvious all the time that someone needs to come back to the code. The particulars only need to be known by the person coming back to address whatever the issue is.

1

If you are a vi user use:

/TODO

It will get you there very fast.

3
  • Other editors have search features and you can just as easily search for todo. Commented Dec 24, 2011 at 3:48
  • Except 'todo' might appear in something else like a variable name, or other comment text... Commented Dec 24, 2011 at 9:38
  • 1
    vi is case-sensitive. Since caps are used sparingly in most modern languages (in things like named constants), the search has a high probability of success. Commented Dec 24, 2011 at 22:19
0

Visually ALL CAPS stands out, but isn't very legible. When reading code they scan as a block of a particular size. It doesn't really matter what the letters are. They just stand out and can be seen very quickly. Once you have been working with the tags for a while, your brain will recognize the word by shape.

From a tools (IDE/Editor) standpoint, case sensitive search will have a very low false positive rate on all caps versions. In some coding styles there is a small risk that a constant will be matched. Case sensitive whole word search makes false positives even less likely.

Once the tool gets it on screen the format clearly says look HERE. Once you are focused on the location, the legible part will be the related comment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.