DEV Community

Discussion on: How banks handle our balance, technically?

Collapse
 
kspeakman profile image
Kasey Speakman

I've never written software for banks/financials, but the event sourcing guy (Greg Young) did...

In your #2, the bank probably wouldn't recalculate the balance on every reading. They would keep the transactions as the source of truth, and the account balance in a secondary model (for example, a different table). As new transactions are entered, the secondary model is also updated to reflect the effect on the account balance. So there isn't a heavy cost in reading balance information. In effect it is doing the same thing as the account balance column, but it is an optimization, not the source of truth. I'd also recommend looking at Pet Helland's article, Accountants Don't Use Erasers.

At the end of the day, you have to find out how the business itself works and model software to match that. Concurrency and other issues are human problems as well as digital ones (how often do you see two people writing on the same piece of paper at the same time?), so the business likely and necessarily already has policies and procedures in place to deal with it. I usually find that modeling the way the business works obviates many technical challenges.