Implementation of a financial account template in Clojure: ref or agent?

I make my way through Fowler 's Sample Analysis and Clojure programming examples for myself as a way to develop a better understanding and others.

Putting on retention / longevity issues at the moment 1 , it seems that Clojure refs with syncing them would obviously be the best approach.

On the other hand, given the posting rules that are triggered by the entries in the account, creating more transactions in even more accounts may be better for agents and their asynchronous updates. At the moment, it looks like I might have to try a little. Anyone have any suggestions for this particular design decision?

1 I suppose that if I get functionality and concepts that work beautifully, I can turn all this into a reasonable database schema.

+4
source share
1 answer

All mutable objects in Clojure are designed to provide a consistent view of how things change over time . If you have several objects that are changing in relation to each other, you need to create a timeline that includes all of them, and the links are intended only for this purpose.

You might also be interested in the concept of observers (add-watch reference key fn) , which you can add to refs to force the use of transaction invariants.

+4
source

All Articles