What is Idempotence?

Got asked this question the other day and my mind pulled a blank on me. However an idempotent method is really straight forward. It’s just a method that no matter how many times its called the result state will always be the same, you can call the method many times without concern.

A good example of an idempotent method is the close() method on a data connection, you call it once, it closes, you call it a second time? Still closed, a third time? You get the idea.

This answer on the question of “What is idempotence?” on Stackoverflow explains it really well: http://stackoverflow.com/a/19320202/1445352

Resource: https://en.wikipedia.org/wiki/Idempotence

Advertisements

Published by

Alan Feekery

Developer, Gamer, Musician, Cyclist and big Motorsport fan... enjoys the odd cup of coffee :)

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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