Optimistic locking is the go-to solution if your backend is stateless (e.g. REST) and/or editing conflicts are rare. In a nutshell, the idea is to allow concurrent access to a resource, but, upon trying to save the updated resource, check if the resource has been updated by other users in the mean time.

Now, from a UI perspective, what do I do once I found out that user A cannot save their changes because user B changed the same record in the mean time? In a shopping cart scenario, it might be sufficient to tell user A that item X is no longer available, but what do I do in data entry heavy applications (for example, if the record in question is a screen full of text boxes)?

I could come up with the following options:

  • Design a complex UI to show the changes side-by-side and aid the user in merging them. That would obviously be the most user-friendly option, but it is extreme overkill for situations where you have (a) lots of different types of records that can be modified (where you'd have to design a merge UI for each one) and (b) editing conflicts are possible but rare (so a lot of those merge UIs might never in fact never be used).

  • Overwrite/Discard/Cancel. This was our first idea, and this is what I have already seen in use in the wild (IIRC, this is what the end-user database MS Access does when detecting an edit conflict). In a simple message box, inform the user about the edit conflict and allow them the choice to (a) overwrite the other user's edits, (b) discard their own edits or (c) return to the edit form and continue to ponder on what to do now.

  • Return + Discard with guidance. This is my idea to improve the previous point: I can't see a good use case for blindly overwriting another user's edits, so I'd drop that option and provide guidance on the other two options. Basically, I'd like to

    a. inform the user about the problem,

    b. tell them to return to the edit UI and make notes about what they have changed, and

    c. tell me when they are done so that I can reload the form with the current version so that they can re-apply their changes and try again.

I'd like to solicitate feedback on two points:

  1. Is this a good idea? I mean, there are probably thousands of applications out there at the moment that use optimistic locking, so I feel like I am re-inventing the wheel by thinking about this issue. Is there a better, go-to solution for this issue? It should be as user-friendly as possible, but not involve having to design a dedicated merge/compare UI/logic for every different kind of record.

  2. If this is indeed a good idea, how do I guide the user through the process without slapping a message box with a wall of text into their face?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.