Sunday, November 25, 2012

Tip: Confirm All Destructive or Irreversible Actions | Blog

Tip: Confirm All Destructive or Irreversible Actions | Blog:
One of the (many) beauties of Lotus Notes is being able to quickly add an Agent to do almost any task. They get used (and abused!) all over the place.
Most of the databases I see are almost always littered with Agents written to perform one-off data-cleansing tasks, but are left hanging around waiting to do damage.
The other thing I always see is badly-named Agents whose purpose is not entirely clear from the name alone and a review of the code itself is needed in order to work out what it does.
The danger with badly-named Agents is that an unsuspecting user can click on them, merely "to see what it does". Or they may click it accidentally. If the actions performed by the agent are irreversible then this is a bad thing.
What I always try to do when writing these kind of Agents is having the following code right up at the top:
If MessageBox("This will delete ALL documents!!!! Are you sure?", _
52, "Confirm") = 7 Then
Exit sub
End If


Which gives us:

image

It doesn't take long and could save so, so much hassle in the long run.

The Java equivalent is:

int option = JOptionPane.showConfirmDialog(null, 
"This will delete ALL documents!!!! Are you sure?",
"Confirm",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);

if (option == JOptionPane.NO_OPTION ) {
return;
}


Which looks like this:

image

Always, always warn the user what they're about to do. They might well ignore the dialog message completely, but at least you can say you warned them...
Click here to post a response

DIGITAL JUICE

No comments:

Post a Comment

Thank's!