A brief explanation of how to leverage your business logic code as much as possible by Simplifying it, with some specific tips for Clojure developers, including using the cross-platform tick date/time library.
The idea to 'Separate Decisions from Dependencies' is to only use pure functions for writing code that 'makes decisions' and wire those functions together as necessary with all the plumbing bits of your system (that'll get your data to and from databases/services/users etc). Rich Hickey would call such a separation a Simplification.
Maybe you think you are doing this already, but ask yourself:
Is all your business logic available cross-platform?
For Clojurists that means your business logic is (or could be) in .cljc files. For JS/Node developers that generally means all your business logic modules are free of IO.
Doing this should be zero-cost, but I rarely see it in the wild.
Many authors and speakers have expounded the virtues of Separating Decisions from Dependencies or Isolating Computation From State , typically citing reliability/testability/visibility as benefits. I am totally in agreement with them, but why go further and say Decisions code must be cross platform?
Thinking here of a typical modern web/mobile application, we have situations like:
In all these situations we need to have the same logic wherever the app runs.
Cross-Platform business logic is not typically available in stacks where the various app components (web ui, mobile app, server) are on disparate platforms. Clojure and Node are two stacks where I've personally used this idea to great effect, including on Mobile applications written on React Native.
Briefly stated, if you've not got cross-platform logic the problems you might have are:
The JVM and JS runtimes differ significantly, for the purposes of business logic that usually means:
Discuss this post here.