3 ms·
Nice article. It’s especially good to contrast FP because my first reaction was “this is FP!” but of course you can write code that ties data to code in Haskell
by quickthrower2 6y ago
Nice article. It’s especially good to contrast FP because my first reaction was “this is FP!” but of course you can write code that ties data to code in Haskell. You could for example have a smart constructor and only allow privy functions to return derived data, and then let the data structure get tightly coupled.
I like “denormalised” data too. Not sure if you mentioned this idea but in React code posted online i see time and time again derived data stored in state and mechanics to keep that up to date. I bet it’s some kind of performance optimisation but most of the time it ain’t worth the trade off (run a profiler instead!)
It’s better to avoid derivable data in the data because you can write a function to do that on the fly.
A typical example is to store the state of a check box and also the state of whether a part of the ui is collapsed or not which can be figured out from the checkbox.