In computer science, the term idempotent means an element whose value remains unchanged after repeated calculation. Consider the example of a hospital information system that adds one day to the length of stay for a patient record. It would be important that the system performs the addition the first time and ignore other requests within the calendar day.
To provide an example of this design pattern, we will create a hospital information system that maintains patient records. Each time an event occurs with a patient, a message is sent to update the number of days the patient has been in the hospital. It is important that we do not count the patient as being at the hospital more than once per day, to avoid overcharges.
The source code for the implementation of the idempotency design pattern is provided in the next section.
...