DEV Community

Álex Sáez
Álex Sáez

Posted on • Originally published at alexsaezm.com on

3 2

To Do

I love TODO comments. And also FIXME comments. Well, I love any piece of non-code text that helps me with my tasks.
I know some people consider them smelly, and you must never use them or, at least, commit them.
I encountered many teachers at my university who always tell this to the students. And I think it is awful advice.

As far as I know, there are two main motivations against TODO comments.

  • First, you should track these kinds of things in a bug or issue tracker.
  • Second, if you collaborate with multiple users, and everybody uses TODO comments, they lose all of the significance because you can't track what is yours and what is not.

The first is a little more tricky to answer, and I can understand the sentiment, but only some things are worth the time, and some of the projects behave differently.
Generally, a FIXME or a TODO is usually smaller than a real issue or bug. A genuine issue should be tracked in a proper tool that allows a conversation among the developers at least. If it's a small thing like "I need to check this later", use a TODO comment. Apart from that, they are totally ok if you are working on a pull request. You can remove them later if they are not meaningful.

The second is true. But not using comments is not the solution. The solution is to make them right! I'm going to tell you the most simple and stupid thing I added to my workflow in the last months (I think I've been doing this for a year now).

Instead of doing something like this:

func hello() {
    // TODO I need to change the text later
    fmt.Println("Hello world!")
}
Enter fullscreen mode Exit fullscreen mode

Try using your username in the control version system, in my case:

func hello() {
    // TODO(alexsaezm) I need to change the text later
    fmt.Println("Hello world!")
}
Enter fullscreen mode Exit fullscreen mode

And then, here's the trick. A lot of IDE and editors allow filtering comments based on regular expressions!

In my case, I mostly use Goland nowadays, but it works in all JetBrains products.

Go to the TODO tab, click on the filter icon, and select Edit filters:

Go to the TODO tab

Then, add something like this:

My TODO filters

And enjoy your useful comments!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay