"Undo" is one alternative to warning dialogs that users learn to click through mechanically.
There's at least one other: if you're going to implement some irreversible action, find a way to delay it --- like in email programs or file managers where the button labeled "delete" moves things to a trash folder, and the real deletion operation is separately labeled "expunge". Implementing this sort of thing is usually easier than keeping the "real" delete operation, and then implementing a separate "undelete" which works in full generality.
That's even worse. Users habituate themselves to the two-step process in exactly the same way, only now they're annoyed because you're forcing them to do extra unnecessary work.
There's at least one other: if you're going to implement some irreversible action, find a way to delay it --- like in email programs or file managers where the button labeled "delete" moves things to a trash folder, and the real deletion operation is separately labeled "expunge". Implementing this sort of thing is usually easier than keeping the "real" delete operation, and then implementing a separate "undelete" which works in full generality.