- for "missing?" we often need to query database to check if an item exists. If predicates are truly independent, we will need to do the query again to return the item.
- "data flow" looks something like this (in Prismatic's Graph lib):
(def stats-graph
{:n (fnk [xs] (count xs))
:m (fnk [xs n] (/ (sum identity xs) n))
:m2 (fnk [xs n] (/ (sum #(* % %) xs) n))
:v (fnk [m m2] (- m2 (* m m)))})
or as a picture:
This is basically a data structure that more-or-less explicitly encodes data dependencies between functions and allows to check stuff like "all data needed for a function is already computed when it's called".
On the other hand, "decision graph" (it can be encoded as FSM, as in the case of your HTTP decision diagram) is all about callbacks and outcomes. In all practical implementations that I've saw, callbacks were allowed to pass something "downstream" (in state
or query
) to solve the problem mentioned in (1). However, this introduces implicit data dependencies between callbacks that are inferior to explicit "data flow" model.
Therefore, it seems preferable to somehow "merge" both approaches, but I don't know yet how. It would be interesting to hear your thoughts on this.
ok, thanks. now i'm with you 100%, i think :)
rather than passing stuff downstream, my thoughts were at some early stage to re-think callbacks with "downstream" dependencies. in your example,
missing?
would be dependent on someget
callback, which can be modelled abstractly, for instance with Graph.reversely, if you want to deal with the optimization first, rather than modelling the dependencies abstractly, one could use memoization and indirection so that
missing?
would callget
, returntrue/false
and not put anything in the opaque bucketneed to digest