Unfinished hyperlinks - add a todo

Tim Abell · May 25, 2013

Just a quick post;

<div style="text-align: center;">href=”#”   ==>   href=”#todo”</div>
I’d like to promote a change to the habit of using ‘#’ as the placeholder for a the url of a new hyperlink when you don’t yet know where it’ll link to: instead set the href to “#todo”. This follows the //todo pattern recognised for unfinished code, and means you can now search your codebase for any links you forgot to finish off.

<a href="#">new link</a>
   becomes
<a href="#todo">new link</a>

<div>eg: new link becomes new link

Give all these links an alert with the following (cheers to unknown in the comments)

$("a[href=#todo]").click(function () { alert('Not implemented yet.') });

</div>It will also give clues to any sharp-eyed testers / users that they should report a bug for you as the url will change to #todo when the unfinished link is clicked. It can often be seen in the status bar too.
This has the handy side-effect of avoiding the annoying jump to the top of the page that is the default behaviour when you click on a # link that’s a placeholder.
<hr /><div>For bonus points another little trick I like is to add a click handler with an alert to make it really obvious to any early users / testers that this is not done yet, and I’ve found this saves a lot of questions when you genuinely haven’t finished, and also guarantees a quick bug report when you should have (not that I ever forget any of course :-D) </div>
<a href="#">new link</a>
   becomes
<a href="#todo" onclick="alert('Not Implemented');">new link</a>

<div>eg: new link becomes new link  <= click this to see the alert</div>
Simple and effective.

If you agree, please help spread the word. Perhaps by retweeting my tweet

<hr />
P.S. This goes hand in hand with a technique of picking points during development at which there should be no todo’s left in your codebase with the exception of those with references to outstanding user story / bug numbers. I suggest before marking a user story as done, and at the end of each sprint as good points to review all todos in your codebase.

Further reading:

<ul><li>The case against TODO - wordaligned.org</li><li>Using a JetBrains IDE to manage todos</li></ul>

Share: Tweet | LinkedIn
Suggest improvments: page source on github