A colleague referenced the Microsoft Restful API Guidelines, which require put and delete to be idempotent.

Say what?

I’m more used to thinking of functional programming being idempotent. I.e., the square root of 2 is always the square root of 2, no matter how many times you calculate it.

That kind of operation is idempotent. But it’s also possible that idempotent operations will change state the first time they are executed. What is required is that subsequent operations not change state.

Put another way, there is no difference in executing an idempotent function once or a jillion times.  Which is not to say that there is no difference between executing it once or never.

I believe the major constraint this imposes is that a REST-ful delete must identify its target by a locally unique ID rather than an index.  And a REST-ful put must have a way of identifying a record so that attempting to add a second time is effectively a no-op.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s