Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

idempotent

 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding idempotent my findings in API and specs.

doGet
The GET method should be safe,The GET method should also be idempotent

doHead
Make sure that the doHead method you write is both safe and idempotent

So these two methods are idempotent



doPost
doPut
doDelete

This method does not need to be either safe or idempotent
So these three methods are not idempotent


doOptions
doTrace

these mehtods doesn't give any thing about idempotent.
Are these 2 not idempotent


Please do provide your view also.

[ August 20, 2008: Message edited by: Chintu sirivennela ]
[ August 20, 2008: Message edited by: Chintu sirivennela ]
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Idempotent means side effect if we call the same method two times.
now try to make a decision with the meaning of idempotent and working of method.

for example:
doDelete :- one you have deleted the data based upon a particular condition, no matter how many times you call the method the data is already deleted.
so there should not be any side effect. hence this method is Idempotent.

But the exception to this problem is that if after deletion fresh data is generated then in the second time fresh data will be deleted. so idem potency of method depend upon circumstances.
 
Balaji Natarajan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. doOptions will give you the HTTP methods supported by the server.
How many times you call this, you will get same response. There is no side effect in calling this many times.

2. doTrace will give a copy of what server has received at the other end.
Think here too, idempotency is not be worried as the response depends on your request.

Hence, well, these two methods can be called as 'Idempotent'
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Balaji and Sunny

So finally I can say

idempotent methods are :
1.doGet
2.doHead
3.doOptions
4.doTrace

Non idempotent methods are :
1.doPost
2.doPut
3.doDelete

Am I correct
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
only doPost() in non-idempotent
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi seetharaman,

I also read many places only post is non-idempotent but see my post that is from specs and API after reading that come to a conclusion.

I am also plaaning to come to a conclusion besed on the opinions of ranchers.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sunny Jain:
doDelete :- one you have deleted the data based upon a particular condition, no matter how many times you call the method the data is already deleted.
so there should not be any side effect. hence this method is Idempotent.


hi cinthu , how about this ?
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually whether the method is idempotent or not, it depends upon the implementation. If you don't override the doGet method it can be non-idempotent. for example : if you delete the first row of table.

when the question comes to you about idempotent you should think the ideal implementation of the method as per the name of method indicate.
in such concern put and delete are idempotent.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic