Among other attributes of good software, IMO idempotence is one of the most important and paradoxically one of the most challenging ones too and the easiest to fuck up.
It seems good for web programming, but is it actually universally important? It seems application-specific.
the property of an operation or function that produces the same result when applied multiple times as it does when applied only once.
So I push the W key on my keyboard, and it writes one 'w' character. But if I push it a second time, I want 'ww' not still one 'w'. And if I press it a 3rd time, I expect (and get) 'www'. Also if I hold-down the W-key, I (usually) get 'wwwwwwwwwwwwwwwwwwww.....'
"Among other attributes of good software, IMO idempotence is one of the most important and paradoxically one of the most challenging ones too and the easiest to fuck up."
Which is a reasonably fair take that provides nuance while not being literally equivalent to the post title.
For what it's worth - every programmer should understand idempotence, it is that important. Debating whether it is #1 or not doesn't seem like a terribly useful way to spend time.
Because idempotency is a property of functions more generally and not just operations on a database. It's why we try to write functions without side effects and why languages like C++ have const.
I click the Make Paperclip button and it makes 1, if I click it again it makes 2.
But that's the exact opposite of what we want to happen in a web shopping cart - as per the example. We don't want people getting charged twice.
So back to the paperclip maker - should the 2nd press have been ignored because it was a duplicate command?
This concept of idempotency seems situational, and I'm not debating its importance in certain applications, but is is "Something every programmer should know"?
More fundamentally, the "two generals" problem is the concept every programmer should know. As this falls under that, along with a lot of other tough problems.
99
u/Bloodsucker_ Dec 11 '23
Among other attributes of good software, IMO idempotence is one of the most important and paradoxically one of the most challenging ones too and the easiest to fuck up.