How do you flag code so that you can come back later and work on it?
Solution 1
Mark them with // TODO
, // HACK
or other comment tokens that will show up in the task pane in Visual Studio.
See Using the Task List.
Solution 2
Todo comment as well.
We've also added a special keyword NOCHECKIN, we've added a commit-hook to our source control system (very easy to do with at least cvs or svn) where it scans all files and refuses to check in the file if it finds the text NOCHECKIN anywhere.
This is very useful if you just want to test something out and be certain that it doesn't accidentaly gets checked in (passed the watchful eyes during the diff of everything thats commited to source control).
Solution 3
I use a combination of //TODO:
//HACK:
and throw new NotImplementedException();
on my methods to denote work that was not done. Also, I add bookmarks in Visual Studio on lines that are incomplete.
Solution 4
//TODO: Person's name - please fix this.
This is in Java, you can then look at tasks in Eclipse which will locate all references to this tag, and can group them by person so that you can assign a TODO to someone else, or only look at your own.
Solution 5
If I've got to drop everything in the middle of a change, then
#error finish this
If it's something I should do later, it goes into my bug tracker (which is used for all tasks).
Randy Stegbauer
I'm a software developer living in Canada. I work with .NET on a daily basis, but dabble in anything else I can get my hands on.
Updated on July 24, 2020Comments
-
Randy Stegbauer almost 4 years
In C# I use the
#warning
and#error
directives,#warning This is dirty code... #error Fix this before everything explodes!
This way, the compiler will let me know that I still have work to do. What technique do you use to mark code so you won't forget about it?
-
Guge over 15 years@Jon T: how about a throw new NotImplementedException(). Would that help you? I sometimes do that too.
-
Randy Stegbauer over 15 yearsThat's a cool idea - I've never thought of assigning things ad hoc in the code.
-
Elie over 15 yearsThanks, we use it quite heavily where I work as a fast way of marking code for other people so that they don't have to search for it.
-
Ken over 15 yearsTODO comes up with a nasty brown background in vim - visual code smells
-
java_newbie over 15 years@S.Lott: any particular reason why you use @todo, instead of the typical TODO? (i'm just curious)
-
Instantsoup about 15 yearsWe've done this but created custom tags for everyone so it's just //NAME: blah blah blah and we share Eclipse configurations
-
Dan J over 14 years+1 For humour value, even though this is absolutely horrible!
-
jbatista over 9 yearsI think //BUG is valid too
-
Jeancarlo Fontalvo over 7 yearsWow, that's nice Mister
-
Johannes Pertl over 4 yearsI use Rider and for me, only
// TODO
seems to work. Using other tokens when working with different IDEs would be a problem then