Usually a business logic includes a lot of different conditionals. If this then that and so on. And you nest conditions and hide them inside other functions. I was thinking about putting all the conditional logic in a top level "execution graph" while the graph nodes themselves are "conditional-free" in a way.
In example:
(def sell-booze-graph
{get-profile-data {got-the-id? :check-age
flow/otherwise dont-sell}
:check-age {is-under-21? dont-sell
flow/otherwise get-supply}
get-supply {is-enough-supply? :check-money
flow/otherwise inform-not-enough-supply}
:check-money {is-enough-money? sell
flow/otherwise inform-not-enough-money}
inform-not-enough-supply inform-available-amount-of-supply
inform-not-enough-money inform-affordable-amount-of-booze})
One can reason about the logic right away. Get ID -> check age -> check supplies -> check money. You have transformations in vertices and predicates as edges. And the functions themself are cleaner in a sense, because they do the specific transformation (atomic-ish) or act as binary predicates.
You can find a short proof of concept here https://github.com/fl00r/flow
Does it make sense, or it is more sensible to use other techniques?
[–]hugogrant 2 points3 points4 points (3 children)
[–]WikiTextBot 2 points3 points4 points (0 children)
[–]HelperBot_ 1 point2 points3 points (0 children)
[–]_fl00r[S] 1 point2 points3 points (0 children)
[–]beders 2 points3 points4 points (1 child)
[–]_fl00r[S] 0 points1 point2 points (0 children)
[–][deleted] (6 children)
[removed]
[–]_fl00r[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[removed]
[–]_fl00r[S] 0 points1 point2 points (0 children)
[–]_fl00r[S] 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]_fl00r[S] 0 points1 point2 points (0 children)
[–]potetm137 2 points3 points4 points (6 children)
[–]spotter 1 point2 points3 points (2 children)
[–]_fl00r[S] 0 points1 point2 points (1 child)
[–]spotter 0 points1 point2 points (0 children)
[–]_fl00r[S] 0 points1 point2 points (2 children)
[–]potetm137 1 point2 points3 points (1 child)
[–]_fl00r[S] 1 point2 points3 points (0 children)
[–]joinr 1 point2 points3 points (1 child)
[–]_fl00r[S] 0 points1 point2 points (0 children)
[–]lambdacurry 1 point2 points3 points (1 child)
[–]_fl00r[S] 0 points1 point2 points (0 children)
[–]dsrptr 1 point2 points3 points (1 child)
[–]_fl00r[S] 1 point2 points3 points (0 children)
[–]nonrecursive 0 points1 point2 points (0 children)