I'm looking for a word to describe the relationship (or perhaps paradigm) wherein two functions go together and are meant to act as opposites to one-another, or to reverse each-other's behaviour - especially in programming.
For example:
Read
andWrite
Serialize
andDeserialize
Encrypt
andDecrypt
- Perhaps more of a stretch:
Constructor
vs.Destructor
oralloc
vs.free
More specifically (or perhaps more generically), I am striving for words that capture a certain guarantee or expectation that any set of 'paired' functions, when given the same configuration (or complimentary configurations), can operate on one-another's output. In the above examples:
Write(data, format) => file
such thatRead(file, format) => data
Serialize(object, settings) => string
such thatDeserialize(string, settings) => object
Encrypt(string, privateKey) => data
such thatDecrypt(data, publicKey) => string
When using such functions there's an "expectation" that if e.g. a given library is used to write out a file to storage, such as:
hive.write.format('csv').header(true).partitionBy('date').save(path)
That the output of that function call can be read back in by its 'opposite', when provided the same configuration:
hive.read.format('csv').header(true).partitionBy('date').load(path)
If the above didn't work - that would be weird, and might be considered a bug in the function design or implementation. It would violate some pattern or common-sense expectation, I'm just not sure what one would call it.
There are other words in programming to describe guaranteed behaviours (such as "orthogonality" and "immutability") and relationships functions/operators have with one another or their outputs (such as "commutative" and "isomorphic"). I was hoping there would be a similar word for this.
In mathematics, I'm familiar with the concept of an "inverse function" which can consume the output of another function to restore its input (e.g. unary functions such as log
and exp
) such that F(x) = y, F'(y) = x
, or perhaps more interestingly F'(F(x)) = x
(e.g. they 'cancel one-another out'). It is quite close to the concept I'm thinking of.
Some words that come to mind are "pair", "symmetrical", "complimentary", or "opposite" functions, but I'm not seeing anything in academia using these words in this way.
I'd settle for a word or set of words that works in any of the following contexts:
- The
Biggify
andSmallify
functions are (adjective) - The
Biggify
function (verb or phrasal verb) theSmallify
function. Biggify
is the (noun) (preposition)Smallify