An action is considered idempotent if you can execute it multiple times and the end state produced by it will always be the same.

A remote control in the carkeys with two buttons, one only for closing, one only for opening the doors. The button on the bottom is for opening the doors only. The button on the top is for closing the doors. No matter how many times you press the button, you can be sure the car will get closed right after pressing it. Therefore, those buttons are idempotent.

Idempotent buttons

A car remote with just one button is not idempotent. Press it once, the car doors open. Press another one, the car doors close.

Non-idempotent button

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s