Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>This use-case has been achieved using a single Clojure variable.

Can you expand more on how the business rules are executed with the variable ? Maybe a simple example ? Clojure-newbie looking to learn more :)



Eventually you want non-developers to develop business rules, so you come up with pseude-code like

  when X then do Y
You can write them in Clojure like in the above example:

  [:rule [:when X] [:then Y]] 
which is kind of self-explanatory. X and Y can be any valid predefined expressions, e.g.

  [:rule [:when [:< amount 100]] [:then [:send-email-to-boss]]]
If you had such a rule, you'd just parse that line as edn, substitute all symbols (check for injection attacks) and execute it.

However, effectively clojure itself is most often the smallest representation:

  (when (< amount 100) (send-email-to-boss))
It's just not that readable because it's missing the "then", but it would be valid clojure right away.

In the end it's like a code snippet that non-developers can write without having to set up a compiler, run-time, syntax-checker


from my experience im very sceptical each time when someone says that business people will write these rules. on paper it looks nice but at the end if rule is a bit more complicated developers end up writing or updating the rule while someone standing behind their back :)


I’ve seen business people write rules in excel. A. lightweight dsl with a quick feedback loop (provided by a REPL in Clojure, and the UI of excel) seems to be key features to avoid ending up in the scenario you describe




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: