DEV Community

Gerardo Antonio Gerónimo Vasconcelos
Gerardo Antonio Gerónimo Vasconcelos

Posted on

Optimistic UI and the balance between speed and precision

Just as in life, always assuming everything will be alright may not be the healthiest, no matter what kitten posters say.

A concept that has been in vogue for a couple of years now is the Optimistic User Interface. It's a design technique that enhances the user experience by showing immediate changes in the interface, before receiving confirmation from the server.

The initial phrase alludes to the fact that in a world where everything goes fast, we want to give our users a sense of speed and fluidity. But sometimes, this can cause us trouble.

One of the risks of using this technique is provoking a race condition, which occurs when two or more processes access the same resource at the same time.

How could something like this happen? Imagine a home delivery pizza application, which connects to an API. It allows you to save your ingredient preferences, but today you feel like swapping the cheese for ham; so you save the changes and place the order, and you get the message that in 10 minutes you'll have your pizza at home.

The thing is, the API received the change in preferences and the order at the same time. And the order was made with the previous preferences, before they were updated. Imagine your face when you see your pizza with cheese!

While it's possible this is due to poor architecture, these types of changes are usually harder and more costly to make. A simpler solution would have been to wait for the change in preferences to be confirmed before placing the order.


An Optimistic UI can enhance the experience by showing immediate changes. However, it's important to keep in mind the risks and take measures to prevent issues. By balancing speed and accuracy, we can offer an optimal experience.

Top comments (0)