Which one is the better option and why?
Delete with Confirmation [The action cannot be undone]
Delete with one click [And provide option to Undo]
The site Good-UI argues for Undo: Try Undos instead of prompting for confirmation.
Imagine that you just pressed an action button or link. Undos respect the initial human intent by allowing the action to happen smoothly first and foremost. Prompts on the other hand suggest to the user that he or she does not know what they are doing by questioning their intent at all times. I would assume that most of the time human actions are intended and only in small situations are they accidental. The inefficiency and ugliness of prompts is visible when users have to perform actions repeatedly and are prompted numerously over and over - a dehumanizing experience. Consider making your users feel more in control by enabling the ability to undo actions and not asking for confirmation where possible.
I would tend to agree. Respect the user's ability to rationally think through and perform the action they intended. But give them the opportunity to pull back if necessary.
This isn't to say that confirmation dialogs are never appropriate. It depends on the situation. The inability for the system to retract an action is, of course, one reason to use a confirmation.
Doesn't work as well as:
Here are some other examples of where an "Undo" action is used in place of a confirmation.
Gmail has a Labs feature that allows you to undo a send action on an email.
In reality the system simply delays the actual send action and allows the user to retract the request before the send really happens. But to the user this doesn't really matter -- Gmail's ability to magically recall (in short history) an e-mail I accidentally sent is all I need to know.
When you delete a file in OSX, most of the time you don't get a dialog box asking you if you are sure. You actually take a "Move to Trash" action. In this instance you can undo the action by restoring the file from the trash (just like the physical world metaphor this action is modeled after).
This changes when you attempt to delete a file from a network drive, or other location where OSX can't move the file the trash can. In this case you do get a confirmation window telling in, very plainly, that if you continue you will never see the file again.
Delete with confirmation looks like this:
Assuming the user tries to get from 1 to 3 (ie, she intended to perform action 2), the user has no interest in step 2b.
We put delete-guards in place to reduce user errors, but if the action was intentional (which it is more often than not) step 2b is superfluous.
Undo, on the other hand, looks like this:
Here, the user travels from 1 to 3 in less steps (less performance load), but still have the option to get back to 1.
So whether UX or graph theory - the latter option is superior to the former.
As Mayo pointed out, there are some exceptions though. Like when the expected user intention is to permanently remove something, as with privacy concerns.
As a counter-argument to the (well-expressed) claims already stated in other answers, confirmation dialogs should be used when an action is not performed often and difficult to reverse. A common example is installing a program on your computer:
Windows machines provide this confirmation dialog any time a program requests access to your administrator privileges because allowing any program to do anything to your hard drive can have dangerous consequences. Otherwise, users may not even realize when they're harming their system.
Before deciding whether or not to use a confirmation dialog, ask yourself how much impact on the system an accidental delete would have. If it just means remaking a setting or item, the extra step is likely not necessary. If it means that your system will have a security vulnerability until the original state is restored, I would suggest asking for confirmation just to be safe.
In the general case, I agree with Evil Closet Monkey: Undo creates less friction than Delete, so it is preferable. But there is at least one case where Delete+Confirm is preferable: When your users are overwhelmed.
A user is overwhelmed when he wants to complete a task, but has no idea how to do it, and expects to fail. It can be so subtle that the user himself does not realize what he's experiencing, or it can ramp up towards obvious panic. Once you know the state, you can recognize it during user observation. Some users will always be in this state when interacting with a computer ("This machine hates me!"), others will only enter it when faced with a completely novel challenge and left to sink or swim without any visible support.
A user in the overwhelmed state has tunnel vision. He will miss important and obvious cues. He is also acting as if he were scatterbrained - he'll often choose to do obviously wrong actions, without realizing they are wrong. Note that the probability of entering this state does not correlate with intelligence - I have seen prominent STEM researchers in it - and the user within this state will do very stupid things, even if he's normally a very intelligent person.
As a result, the overwhelmed user is quite likely to 1) click the "Delete" button by mistake, and 2) overlook the "Undo" message. So, the whole protection mechanism fails. And to add insult to injury, once the user realizes that his data is missing (which might be days later), it registers as one more unseen danger lurking in the computer interaction, reinforcing the feelings of helplessness which cause the overwhelmed state in the first place.
On the other hand, when the overwhelmed user clicks "Delete" by mistake and is greeted by a modal dialog asking for confirmation, 1) he cannot overlook it. (in the worst case, he will wonder why nothing else works until noticing it). 2) He realizes that, in this system, there is obvious protection preventing him from getting into real danger. This helps him relax a bit and lower his guard, which reduces the intensity of the overwhelmed state. The intrusive nature of the modal dialog, which is mildly annoying to a confident user, is a boon for the panicked/overwhelmed user.
I have observed overwhelmed users interact with both types of system, and I can tell you from experience: If you have reason to think that most of your users will be in the overwhelmed state, choose the Delete+Confirm option. This can be the case when you have e.g. elderly users (they have less computer experience and find it harder to learn new things, so they are frequently overwhelmed, at least slightly) or you are implementing a system which is obligatory for employees in job positions with high job fluctuation and little to no training.
There would be a third way that i actually chose to implement in a small cms ui – and the clients seem to be happy with it so far. I also wanted to avoid the confirmation message and implementing undo just wasnt an option. So instead of adding an additional step after the user already tried to delete the content, I added a step before the user does so – so first have to 'unlock' the delete button - and then it's just one click.
Technically it's almost the same as a confirmation screen. The actual user experience however seems to be quite different. The user is treated as if he was rather 'in charge' than 'insane'.
You want to copy a folder full of files from one location to another so you begin the operation and the computer is nice enough to let you know that files are copying and that it will take about 2.5 hours to complete. Cool so you decide to go run some errands and grab a bite to eat and when you return you are greeted with this.
If the user is properly aware of the delete operation and there is an easy way to undo it then it doesn't qualify as catastrophic and it's better to not block the user.
I think the Android Gallery "filmstrip view" and its swipe-down-to-delete is a strong counter-example for the idea that "delete and undo" is preferable. It's easy to accidentally delete while trying to browse, and the same type of action (unintentional touching) that deletes can also move you away from the opportunity to undo.
To me, this is a huge UX failure. It doesn't necessarily mean "delete and undo" is a bad interface model, but it suggests to me that whenever you're offering an option to delete without confirmation, it should be extra difficult to navigate away from the opportunity to undo, or alternatively undo/undelete should be available for a reasonable period of time even after you've navigated away.
I also think you need to consider the severity of the delete operation. If for example you have a DNS setup interface where you're adding/removing RRs, delete is not a severe action, and in the worst case the user can just recreate the deleted record. On the other hand, if you're deleting photos/videos, or VPS instances, or something else that would be either difficult or impossible to recreate, then it's atrociously bad UX to make accidental deletion easy. I would argue you should even need to re-enter a password to delete in these cases.
The main reason for preferring Undo over Confirmation Boxes is laid out by Alan Cooper in 'About Face 2.0, The Essentials of Interaction Design'
Confirmations illustrate a quirk of human behavior: They only work when they are unexpected. If confirmations are offered in routine places, the user quickly becomes inured to them and routinely dismisses them without a glance.
Basically, whilst as others have pointed out confirmation dialogs are initially annoying and disrupt the user's flow, they are even more dangerous once the user becomes used to them and they become part of the flow. At that point they cease to work at all to do what they are supposed to do which is stop the user making a mistake that cannot be rectified.
So allowing users to undo destructive actions provides two benefits, it allows the user to work without their flow being interrupted and it allows them to make mistakes, and correct them without even having to think.
This is to prevent from employees deleting important stuff accidentally. Since "undo" function normally disappears after X seconds. That way, there is a real risk of items being deleted permanently by accident. Confirmation window/notification will give that "extra step" where user needs to take action to confirm the deletion.
I would say this depends on 2 factors - the expertise of your user and the severity of the action. If the delete function is irreversible or a destructive action, it would be a good idea to get the user to confirm intent. This should rule out accidentally triggering the delete function.
On the other hand, if your delete function is a normal interaction done frequently which is reversible, you could bypass the confirm popup. If you consider your user a power user, again you could bypass the confirmation.
It all depends on the type of user and context. If you aren't sure, I'd recommend playing it safe. Think about what's less of a pain for the user; Having to click 'OK' on a popup or accidentally deleting something which could have knock on effects?
Aza Raskin wrote a great article on this subject: Never Use a Warning When you Mean Undo. He explains the psychological reasons why confirmations are inhumane while undo is better for how humans work.
What about the case where the user has many items in her cart and wants to remove several of them. If you have an undo for each item, you end up clutter up the interface and turning a simple delete into a more complex problem (representing each deleted item with an undo action). Do you only have an undo on the more recently deleted item? if do, deleting several items in a row leads to items being deleted, without either an undo or a confirmation dialog.