Sketchplanations

Explaining one thing a week in a sketch

Idempotence, or idempotent, illustrated with an idempotent action of look_at_cake that always has the same effect, compared with a non-idempotent action of eat_slice_of_cake

Idempotence

Idempotence is essentially an operation that, no matter how many times you do it, you’ll still get the same result, at least without doing other operations in between. A classic example would be view_your_bank_balance being idempotent, and withdraw_1000 not being idempotent. It’s a property that’s often handy as you can retry the operation without worrying about unintended effects.

Idempotence is a concept from mathematics and computer science but can be applied more generally. For example, simple on and off buttons are idempotent, a property that can be very useful in emergencies.

Keep exploring

The Two Generals Problem: Two Generals fighting for the same side, have set up their camps on the high ground either side of a castle to be attacked and use a messenger running between them to coordinate their attack. The problem is that the messenger has to run right past the hostile castle to relay the Generals' messages and confirmation of receipt of messages and there's no guarantee they'll make it past the castle unharmed.
Buy Me A Coffee