In the company has been doing with the payment of the project, a certain day to receive a peace of a man telephone, should be a headhunting cast, I happen to eat breakfast (also can not blame them to work early, our company flexible, I usually work late).
Because the restaurant signal is not good, can only hurriedly put down the remaining half bowl wonton (Routong AH), walked a kilometer (that piece of mobile signal is really slag).
Finally, we can communicate normally. The other side let me first pick a project to say, I listen to this routine, cow Ah! The same as before Ali (after the opportunity to talk about that face), is definitely random in my project to find a point to ask, then I began to say that there is a compensation for the scene, the beginning of the design of each client to make the difference, it is difficult to ensure idempotent, and then the design of the client to send total, power and other problems solved Here I reiterate the power of the definition ah, presumably everyone knows, that is, for an operation, multiple executions, side effects are the same, not superimposed. For example I deduct money, if I can not distinguish between the client is the difference is to pay or try again, then it is likely to deduct the guests.
So the question is, why does the total model solve the problem? A gold interview officer caught the opportunity to ask questions, and I noticed his question as if it was a persuasive, tell me, young man, you do not understand idempotent ah, with me here, I know the solution to the power of the scheme is not the same Oh! I did not respond at that time, I think that Daniel should not I explain idempotent, it should be in the examination of me, then I described the scene, if the insurance premiums originally is 10 yuan, the client added 10 yuan, plus a plus, 20 yuan to me, so even if this 20 yuan to several times, the premium or 20 yuan will not change, is this reason
Then the wonderful things happened, the interviewer opened the education mode, the following has been he said, said I this is only business changes, and no real solution idempotent AH (I thought this How not solve idempotent, from the definition to solve the AH), and then said, the difference can also solve the power problems ah, I can solve! I hasten to say, I can also, is to use the only UUID strategy, re-send the words using the same UUID last time, then my side of the service will not do processing fall. He said, you know why not to say, this is the technical positive solution Ah, you tell me what the business is doing ah, you said the fundamental problem can not be solved, or to use this scheme. I said, this is the basic thing, similar interface implementation will do that ah, but because it is the old protocol, this temporary plan changes the least and most economical. Then the interviewer was silent for a while and asked me what you said about your Java experience, and I said a little, but obviously he was perfunctory. Then there was no later.
Seriously, this time the face is really let me deeply hit, the interviewer is Daniel, or only know the wonderful endorsement of it? However, it is because they are the director of the Golden Institute of Peace (perhaps it), I was a slag programmer, this status gap led to my knowledge and experience of my doubts.
But recently saw the great God Jim Webber's masterpiece Rest in practice, I regained my self-confidence, which introduced to the HTTP put method is idempotent, for what, explanation is like (I directly hit Chinese), " Because the put request is idempotent (because the server state is completely replaced by the client state), consumers can safely repeat the operation as many times as they want ... ".
The big God mentioned here is a resource-oriented design concept (ROA), the Put method to update the resources, like insurance premiums, if you think of it as a resource, then each time you should be directly replaced with the new value (total replacement amount), and if you consider the modification of the premium itself as an operation, Each time you need to deduct the amount of money (total minus the difference), then will be destroyed idempotent, and we now most webservice design is based on the operation of thinking, in order to achieve power and introduce a set of complex mechanisms, human added complexity.
A reflection on the design of the power and Roa of a golden flower of peace