3 ms·
Show HN: Principles of Data Oriented Programming
- viebel 6y agoThis article is an excerpt from my upcoming book about Data Oriented Programming. This article is an attempt to illustrate what are the core principles of Data Oriented Programming as I understand them. It is highly influenced by my programming experience in Clojure, but I believe that those principles are language agnostic. Feel free to share feedback, agree, disagree or refine.
- quickthrower2 6y agoNice 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.