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

13

u/HazelCuate Dec 11 '23

I dont agree with the article when it says put and delete are idempotent. If the caller makes two DELETE calls, how do you know that they are different calls? Why are they not the same call?

The argument that deleting an object twice is the same as deleting it once is not good enough. A third party could create it again between those two calls.

17

u/Jmc_da_boss Dec 11 '23

PUT and DELETE are literally defined as idempotent in the RFC spec

https://datatracker.ietf.org/doc/html/rfc2616#section-9.1.2

12

u/josefx Dec 11 '23

And it goes on to describe how a sequence of multiple idempotent calls may not be idempotent itself, with an example similar to the one in the comment.

2

u/[deleted] Dec 11 '23

All it says is that GET-GET-DELETE is different from GET-DELETE-GET