I was reading the paper Out of the Tar Pit authored by Ben Moseley and Peter Marks when I came across the following section on page 25 regarding essential mutable derived data:
Essential Derived Data — Mutable
As with immutable essential derived data, this can be excluded (and the data re-derived on demand) and hence corresponds to accidental state.
Mutability of derived data makes sense only where the function (logic) used to derive the data has an inverse (otherwise — given its mutability — the data cannot be considered derived on an ongoing basis, and it is effectively input). An inverse often exists where the derived data represents simple restructurings of the input data. In this situation modifications to the data can simply be treated identically to the corresponding modifications to the existing essential state.
I don't understand why essential mutable derived data must have an inverse function. For example consider the following JavaScript code:
inputbox.onchange = function () {
outputbox.value = md5(inputbox.value);
};
Here inputbox.value
is input to the system and outputbox.value
is the essential mutable derived data. It is derived from inputbox.value
using the md5
function. However the md5
function doesn't have an inverse. Nevertheless inputbox.value
is still essential, mutable and derived.
So what do the authors actually mean when they say that “mutability of derived data makes sense only where the function (logic) used to derive the data has an inverse (otherwise — given its mutability — the data cannot be considered derived on an ongoing basis, and it is effectively input)”?
Do you have any examples to elucidate their point?