Are You Really Sure You Want to Make a Cancel Button?
Are you really sure you want to create the cancel button for your application?
You know, I might click it.
Not only might I click it, I might click it at the most inopportune time.
I might click it right in the middle of that large file that you are copying, right after you spun up that 2nd thread.
Cancel is a commitment
The next time you consider creating a cancel button, I suggest you think of it as a commitment.
In my world the cancel button has two promises.
- Stop what is currently happening in a non-destructive way.
- Stop RIGHT the F NOW!
I’ve been encountering a good deal of cancel button which don’t obey the basic laws of cancelling that any user would expect.
I have actually been randomly clicking “cancel” whenever I see it, much to my coworker’s dismay.
I started doing this, because I wanted to see how widespread the cancel cancer is.
And it is pretty widespread. A majority of cancel buttons I have been testing neither stop right away or prevent destruction.
I found instead that clicking the “cancel” button in most programs is sure to hang that program for an extended period of time, ultimately causing you to kill the process, and it tends to leave processes half done without rolling them back.
Clearing things up
Let me be a bit clear here. I am not talking about cancel buttons you see in an “Ok / Cancel” dialog. Most of the time those cancel buttons actually work, because they are really operating as “back” buttons, they aren’t actually cancelling a process that is happening live.
I am talking mainly about cancel buttons that cancel an active ongoing activity. For example, cancel buttons in an installer or during an SVN update.
We could call these kinds of cancel buttons “asynchronous cancel buttons.”
But, I need to provide a way for the user to cancel
Good, but don’t lie about it.
There are certain things that just can’t be cancelled.
When I get on a plane, I can cancel my trip when I am sitting there waiting for the door to close. I can even cancel my trip while the plane is taxing to the runway, if I yell “I have been RAPED by a BOMB that is on FIRE!”
But, I can’t cancel my trip, once the plane has lifted off the ground. If I try to cancel it then… well, bad things would happen. Very bad things.
So how come when I am installing your software, or your software is updating its database, I have this shiny little cancel button I can click at any time during that process?
Surely I cannot cancel just any time!
Surely there are parts of the process that cancelling would be fatal or it is too late to rollback.
My point is, if the user truly can’t cancel, don’t present a button that says they can. More specifically, if you can’t obey the laws of cancel 1 and 2 from above, don’t even show a button. Just say “sorry, you can’t cancel this process at this time.”
I don’t even need to know why I can’t cancel. I mean, it will make me feel better if you tell me that the Unicorn Glitter Engine is in a critical state and any disruptions could end life as we know it, but I’ll settle for you just greying out that cancel button or not displaying it at all.
Putting back on the developer hat
I’m guilty of it myself. I know I have created cancel buttons in the past that have caused pain and anguish.
But what can we do about it as developers?
First off, we should be thinking carefully about breaking a long running process into steps. At each step of the way we should consider if it is conceivable to cancel that step without destroying data and hanging the application.
In any long running process, we should be able to identify certain parts which are cancellable and those which do not make sense to cancel.
It is your job as the developer to ensure that if you decide to allow for cancelling that the cancel undoes the existing process and work immediately.
I cannot stress this enough!
This is the behavior that most users expect and the very meaning of the word cancel.
To do this might take extra work. You might have to think a bit more about the threading situation of your application. You might have to think about rollback situations. But, if you don’t do it, your cancel button will become just like the boy who cried wolf and no one will believe them.
And if you're not willing to go through this effort, at the very least, be kind enough to your users to just remove the cancel button, because you can bet I’ll be clicking it!