Idempotent operators and application in computer programs

We have studied about idempotent matrices. How does it apply to computer programming?

An idempotent operation can be defined as:

a. Unary: f(f(x) => f(x)

b. Binary: f(x,x) => x

So, it effectively means that an operation leaves the operand in original /known form.

Why would we need such behavior in our program?

There are various problems that need that data must not lose its integrity after any processing. e.g. A producer and consumer could have agreed on a standard data-format. The carrier layer must make sure that it transports the data, guaranteed idempotent. Carrier is free to process, inspect, play with data; but when it reaches the consumer, you got to make sure that you deliver in the agreed format. Our standard TCP/IP protocol is such an example. An application receives exactly what it expects from TCP/IP stack.

Ref: http://en.wikipedia.org/wiki/Idempotence

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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