DEV Community

Discussion on: Poll: Do You Know What "Idempotent" Means?

Collapse
 
dance2die profile image
Sung M. Kim • Edited

Thank you for introducing the arcane term, that people should be aware of, Thorsten.

I've only heard "of" the term, Idempotent and been using functions/methods without knowing what it was 😅

1️⃣ First example is SQL server not allowing User-defined functions (UDFs) to call stored procedures (sprocs) as sprocs can have side effects (writing/update database) while UDFs do not allow it (as it needs to be pure).

2️⃣ Second example is in React's setState, where it requires to pass a pure function (meaning having no side-effects) to return a new state object instance (for reconciliation optimization).

I've only realized that after reading your linked Wikipedia article under Computer science meaning section in which it reads,

in functional programming, a pure function is idempotent if it is idempotent in the mathematical sense given in the definition.