Fork me on GitHub
#data-oriented-programming
<
2022-02-04
>
Xarlyle015:02:24

Isn't it somewhat dangerous to think about types as business rules? Static types have real impact on implementation detail in code design. Ideally business rules should be connected only to the API specifications of your system, not the implementation details inside it.

parameme15:02:51

Fascinating question. Coming from an information systems background a “domain” is a constraint / subset on the “universe of discourse”. In fact some SQL implementations actually support DOMAIN as a keyword, though unlike the broad user defined type mechanism it was originally designed to be ie, add an IMAGE type, has devolved to mostly be a constrained range on a base type eg. CustomerId being a positive integer. https://crate.io/docs/sql-99/en/latest/chapters/19.html So Rich Hickey’s “just use maps” and the related slide says they are just functions between key and value. Semantics are on the attribute specifically and not the aggregate. How does one reference the attribute? How does one relate the attribute to others? (cf. attribute modeling) Do we have aggregates of dissimilar attributes, collections of those or links between collections? (Embodied by special case attributes that reference others) Is an equi-join between relations a specialised business rule?

parameme06:02:47

Erratum: "attribute modeling" I meant "anchor modeling". https://www.anchormodeling.com/about/

parameme15:02:47

A type could be seen as a range constraint and applicable set of behaviours on a single representable value. A referenced value of a type could be seen as a fact (with some valid time) about the world. But how does one raise it to being “data” without a version independent reference? A symbolic name or navigation path?

parameme15:02:34

Without identification the value is … what?

parameme15:02:19

So the value has meaning beyond a CPU cycle iff it can stored and retrieved and acted on.

parameme15:02:40

And it needs to be known or verified to be valid.

parameme15:02:44

Which means that it is constrained. There are bitpatterns that are a valid encodings about facts capturing a perception of reality. There seems to a spectrum of talking about where those constraints are applied. Datum = A value Information = Data with meaning encoded in static structure Knowledge = Information which can generate new information by induction

parameme15:02:08

Constraints can be by extension - the allowable values are {x, y…} or by intension the allowable values are “a single digit that can only be succeeded by the next in the sequence from the decimal expansion of pi”.

parameme15:02:45

Typically these constraints are either enacted or tested by behaviour - computation - logic operations such as comparison and branching etc. Whether by microcode on the CPU instruction, the compiler or an interpreter something is comparing the bits to determine if the fact is accurate and to use the pattern to make other choices about what to do next (to act on the facts).

parameme15:02:04

To harness the value of computation we abstract up from the instructions on the bits, to the classic base word types (integer, float), base sequence types (strings, arbitrary precision numbers), to memory structures to tables etc etc

parameme16:02:26

Where and how the constraints are implemented is a spectrum. Is it a type enacted by the CPU operation, the compiler? Is it a user defined type in the code?

parameme16:02:24

In this channel we might agree that some facts are so useful that their valid time is sufficient that there may be multiple applications that can consume and act on them. They are shared facts across sessions, applications and even distributed systems. Capturing the value adding constraints on these facts can be an interesting task (especially over time and eventual consistency).

parameme16:02:41

And we need to communicate that value add of capturing that data through time to other people and systems. Embody the current understanding of the meaning of the facts in many ways both between technical systems and other humans (schema diagrams, code and its documentation etc). “Business rules” are terms that is typically used to try and capture constraints on validity OR identify behaviours that will modify the system to the next valid state. In general they are at the interface between fact populations, cardinalities and time. (Invoice will be status:”overdue” if fully unpaid after ?30? days of being generated). But it is encoded in the name the lack of universality - is generally only one or a few businesses that uses these same rules (though the may be parameterised). They generally aren't domain rules, they are choices made by a small groups of organisations about the population and relationships between facts.

parameme16:02:05

If anyone is interested there is a technique that I have found valuable over the years called Object Role Modelling which is based on a Conceptual Schema Design Protocol. A way of moving from natural language analysis to facts, constraints and business rules (and relational models). https://www.amazon.com.au/s?k=terry+halpin&amp;crid=1S59803DSH71Z&amp;sprefix=terry+halpin%2Caps%2C271&amp;ref=nb_sb_ss_ts-doa-p_1_12 Wow - what a ramble. And damn, clojurians has history now. Whoops. Thanks for coming to my TED talk insomniac ramble. Takeaways - values having identity and state over time (but behaviour and validity is where computation comes in). Collections of key -> value functions (maps) is one layer but aggregations to entities and their relationships is valuable when modelling perceptions of reality. Schemata can describe expectations of common structure on populations of entities. (Allows for declarative iteration) Types can encode expectations of structure and behaviour on entities. Where In the spectrum to embody computation best depends upon expected complexities and change rates of entity values, entity cardinalities, structural and behavioural rules.

refset20:02:58

Hey 🙂 ORM is very interesting to me! Have you translated/applied it into Clojure or a Clojure database before?

parameme23:02:52

And me too! Unfortunately no, I haven't yet been able to apply ORM to say a datomic, xtdb or asana datastore. (Day job is Rails and PostgreSQL). Have been curious how they map for a while now so would love to follow anyone working on an example. Looks like Dr Halpin has also moved closer to Datalog with LogicQL which I haven't read up on yet either. https://www.routledge.com/LogiQL-A-Query-Language-for-Smart-Databases/Halpin-Rugaber/p/book/9781482244939

👍 1
refset10:02:38

Ooo, I don't think I realised there was a whole book on LogiQL. It looks like there's a complete online version here: https://developer.logicblox.com/content/docs4/datalog-guide/html/index.html (there's the rest of my weekend sorted...) Incidentally, XT's query engine is able to do some similarly fancy things, like the other day I was looking at https://flix.dev/ where it says "Flix supports Datalog constraints enriched with lattice semantics" and had to stop to double-check we could handle the same problem okay: https://gist.github.com/refset/21b3fc1dec9a6928943073809e13356d (good news!)

👏 1
parameme16:02:48

Cheers, all - thanks for asking the stimulating questions.