TODO - What is it, what is its usefulness and how to use it?

9

I've seen a lot of this "TODO" word, mostly in IDE's and I've always been curious to know what it is.

Example:

// TODO: alguma coisa escrita
código....

Now the questions:

  • What is EVERYTHING?
  • What is its usefulness?
  • How to use?
asked by anonymous 02.04.2016 / 02:12

2 answers

17

You saw this in code. This can be called code tags .

Strictly a comment like any other. It may have a specific meaning for some tool. It is common for IDEs or at least extensions of them to have something that scans code for comments that begin with:

  • TODO: ("to do") Someone [me] needs to sort this out urgently
  • FIXME: ("fix me") There is an error that needs to be fixed here, but it works ( TOFIX: )
  • HACK: ("gambi") There was no other way to solve it to meet the deadline, then I improved
  • XXX: ("attention") Some editors highlight comments with this as something important without specific semantics
  • DONE: ("done") Warn that TODO is resolved. When do I remove this?
  • UNDONE: ("undone") I needed to go back to the original for some reason
  • ASAP: ("as fast as possible") Need to fix this urgently
  • REMOVE: ("remove") This code has been placed just to test something and should disappear
  • NOTE: ("annotation") Just to let you know you have something important now
  • BUG: ("crash") There is a known bug here that needs to be fixed - FIXME specialization - usually has an associated ticket number
  • ISSUE: ("question") There is a question here if it should be anyway
  • ERROR: ("error") You have a reproducible error here - FIXME specialization
  • BROKEN: ("broken") does not go forward even, it's no use insisting - FIXME specialization
  • GLITCH ("failure") Something strange happens here in a very specific situation
  • REVIEW: ("revise") Review this for me, used where you usually do peer review
  • WTF: ("what is this?") They have done a great deal of bullshit here

And other similar ones ...

The tools catalog these comments somewhere, not just in the code, to highlight that the code is not complete or at least needs special attention for programmers not to ignore by accident.

Many allow you to configure what you want, but if you overdo it you can start making it difficult to use, generally the first 3 are very useful (for VIM only the room is considered), the others are variations, specializations, exaggerations or require better tools .

In general there is a more detailed description after the colon. This specific tag serves to help the tool identify the semantics of this comment.

This is a practice of organized programmers. Of course if you stick a lot of them and drop it gives the same thing that not use. In general they should be transient.

Some teams even forbid code with this commited , except in cases that are for communication with other team members. The argument is that if it is a planned thing and not implemented it should stay in the documentation, if it is something that is missing to fulfill the planned implementation then the commit can not be done until complete. Reality prevents the flow from actually being that way, the most that happens is people get it out of the code and mark it somewhere else easier to forget, just to circumvent the silly rule.

Does anyone remember others?

    
02.04.2016 / 02:22
7

This term can be translated literally.

It means "to do", "to do".

It is not something specific to programming languages. It is merely a reminder of things to do, usually a relevant fix or implementation that the programmer decided to leave to do on another occasion.

    
02.04.2016 / 02:25