I am working on this credentials dialog where you would put a username/password, and then wait for things to happen with the backend. Obviously, I need some kind of loading indicator along with a cancel button.

The first thing is, how will I implement this? Assuming we don’t want to close the dialog, the most obvious and naive solution is to remove all views inside the dialog, and show the loading and cancel button. Other possible solutions that beat around that bush are there, but there is a much better solution.

Stand ins! A stand in is basically a way where you quickly swap the original thing with a replacement without anyone noticing. Movie actors due it all the time. You are watching the star riding this car, and all of a sudden he is jumping out of the car. The actual guy who jumps out of the car is a stunt man who stood in the star’s place!

Anyways, the idea of a stand in is to reduce the logic and complexity in the application, as well as promote reusability. If we implement the loading dialog as a stand in, it means that it is a separate component that can be used a lot of other places as well.