hardDesignConceptMidSeniorStaff
How would you design a ledger so that any balance can always be proved?
5 min readUpdated 2026-08-15
Answer
Short answer
Store money as immutable double-entry rows where every movement writes at least two balanced entries, derive balances by summing those entries, correct mistakes with compensating entries instead of updates, and keep each currency in its own denominated account so nothing is ever summed across units.
Was this answer helpful?
Likely follow-ups
- Where does the rounding remainder go when you split a payment three ways?
- How do you enforce "no account may go negative" without serialising every write to that account?
- How would you shard this ledger, and what breaks first when you do?
- What does your daily proof job compare, and what do you do when it disagrees?
Related questions
- How would you design a thread-safe component, and why is adding synchronized to every method not a design?hardAlso on immutability7 min
- When is a factory the right answer, when is a builder, and when should you just call the constructor?mediumAlso on immutability7 min
- If you override equals but not hashCode, what breaks and when?mediumAlso on immutability4 min
- Why does `is` agree with `==` for some numbers and strings but not others?mediumAlso on immutability5 min