Idempotence Again and Again

0 comments suggest edit

Eric Lippert does a great job of defining the term Idempotent. I’ve used this term many times both to sound smart and because it is so succinct.

The one place I find idempotence really important is creating update scripts for a database such as the Subtext database. In an open source project geared towards other devs, you just have to assume that people are tweaking and applying various updates to the database. You really have no idea in what condition the database is going to be in. That’s where idempotence can help.

For example, if an update script is going to add a column to a table, I try to make sure the column isn’t already there already, before adding the column. That way, if I run the script twice, three times, twenty times, the table is the same as if I ran it once. I don’t end up adding the column multiple times.

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.



3 responses

  1. Avatar for Marty Thompson
    Marty Thompson October 25th, 2005

    Man, first you do a proof by induction and now you're using a word like idempotent. You're making me remember all of that stuff I learned in college!

  2. Avatar for jayson knight
    jayson knight October 26th, 2005

    wiki wiki: (as it relates to math as you seem to like stuff like that quite a bit).

    For some reason I want to think of idempotent as atomicity + deterministic, but I'm probably way off.

  3. Avatar for Micah
    Micah October 26th, 2005

    Bob Dole has some interesting stuff to say about idempotency. Apparently it is quite common among males of a certain age. Fortunately there is a cure now.