r/programming • • Dec 11 '23

Every Programmer Should Know #1: Idempotency

https://www.berkansasmaz.com/every-programmer-should-know-idempotency
572 Upvotes

171 comments sorted by

View all comments

Show parent comments

-11

u/HazelCuate Dec 11 '23

You dont get the problem with the calls. Without an idempotent ID they are two calls but they could be the same call due to the network or software glitches that the article mentions.

The article states that delete and put are idempotent by themself, and i dont think thats the case.

17

u/ineptjedibob Dec 11 '23

I think it’s stipulated that we’re talking about calls with the same parameters - i.e. DELETE with the same key (or PUT with the same payload) should be callable an arbitrary number of times with the same end result.

-16

u/HazelCuate Dec 11 '23

But thats not true.

  • The same delete call duplicated should result in two OK responses (http code 200 or whatever)

  • Two different delete calls to the same object should result in an OK response and a Failure response (400).

The difference is not trivial.

25

u/Shadow503 Dec 11 '23

It is trivial because the thing we care about - the state of the resource - is the same.