
Jonathan C. answered 08/09/19
Programmer
Idempotence is a property which basically boils down to "Repeating an operation does not change underlying state"
The most basic way to show this property is to consider the following statements:
- x = 5
- x++
The first would be idempodent. If you repeated the (x = 5) operation a million times, at the end, x would have the same value as if you only did it once. There are more complicated operations that can still be idempodent.
The second would not be idempotent. If you repeated (x++) a million times, the result would be x being increased by a million. If you ran it only once, x would only be one larger than what it was before.
In other contexts the essential nature of property is the same. An http GET, PUT or DELETE operation, for example, are all essentially idempotent, as the end result of the same operation running multiple times does not essentially change the state of the system. (A GET just GETs the data, a PUT updates an entire file, and DELETE removes a file if it exists. Each of these won't change the state of the system if ran multiple times, though a pedant might argue if metadata changes, they aren't idempotent, but I digress)
An http POST operation is not idempotent. Consider if you repeatedly clicked the "Ask Question" button and your browser sent 5 POST requests. 5 copies of the question would be added to the list, instead of just one.
One important thing is that idempotent operations can be retried and not cause problems, without need for verification of failure. An non-idempotent operation (like posting a question) would cause some sort of problem (eg, duplication) if retried without verification of failure.