What does idempotent mean?

When you start to accumulate home theater components to go with your TV, you end up with a bunch of remote controls. One remote for the TV, one for the receiver, and one for the DVD/Blu-Ray player. One for a cable box, satellite, or set-top streaming box. Maybe you’ve got a multiple-disc CD player, or even a turntable. (Vinyl is making a comeback!) Maybe you’ve even still got a VHS?…no I’m kidding, nobody has those anymore.
The solution, rather than dealing with a stack of remotes, is to get one universal remote to rule them all. But once you do, you find that not all components are created equal, at least when it comes to the infrared codes (the actual signals sent by the remote control) that they accept.
A cheap A/V receiver might accept codes like PowerToggle
or NextInput
. These make it nearly impossible to reliably turn the unit on and set the right input, especially if someone has messed with the receiver manually.
A good receiver will have additional codes for PowerOn
and PowerOff
, even though those buttons don’t exist on the remote, and will also have an independent code for each input, like InputCable
, InputSatellite
, and InputBluRay
.
This is the essence of idempotence. No matter how many times your universal remote sends the PowerOn
and InputBluRay
commands, the receiver will still be turned on and ready to watch Forrest Gump. PowerToggle
and InputNext
, however, are not idempotent. If you repeat those commands multiple times, the component will be left in a different (and unknown) state each time.