views:

101

answers:

3

Hi all,

I have made life difficult for the HTML / CSS developers by making any interaction that has a side effect into a button and NOT a hyperlink.

For example I changed the "Clear Basket" in a shopping site from a link to a button. On the premise that any action that has a side effect should be a button not a hyperlink. (even tho a spider or robot will never get to this point) How does this relate to REST?

The best answer will have good reasons I can use as to why I make things difficult for the HTML/CSS guys,... or why I'm wrong :-) ,... perhaps I'm being purist but for no real reason?

Note: I'm not averse to putting ajax functionality that has statefull side-effects on a hyperlink or even on selection-changed event.

Cheers. Murray.

+1  A: 

It does not really matter if your "stateful" actions are links or buttons. You can have a link that deletes/adds, etc. Consistency is what matters. So if you want to have these actions be buttons, that is fine. I think that talented CSS people can make links look like buttons. You may not need html buttons at all.

James Lawruk
I disagree in cases where a spider can get get at the link, you can see the obvious problem.
Myster
Good point to consider. You could use a robots.txt file no spiders would not crawl action Urls.
James Lawruk
Unless a bot is buggy or noncompliant. If you're triggering stateful side effects from GET requests, then *you're* noncompliant, and some day it will bite you.
Thom Smith
+3  A: 

I think you did the right thing but justifying it is probably outside the domain of "REST".

If these links are truly just <a> tags that result in the browser making a GET request then clicked, then they shouldn't have any side effects because GET is supposed to be, per the HTTP spec, safe and idempotent. See earlier comments about spiders following the links, etc.

Now if the "links" used javascript to really do a POST to the server when clicked, or some kind of trick like that, then they are A-OK from HTTP's point of view. Probably more work than they're worth, but RESTful.

But there is user interface design to consider too. Because in basic HTML without CSS and javascript a link is always a GET, users have been trained since 1994 to expect anything that looks like a hyperlink to be safe and idempotent. By doing something different, your designers are in violation the principle of least surprise. This seems like something Jacob Nielsen would back you up on.

Licky Lindsay
+1  A: 

This doesn't really have much to do with REST, but I try to follow this simple rule:

Hyperlinks are for navigation.
Buttons are for interaction.
Mike Trpcic