Implementing the domain model
We want to implement the use case of sending money from one account to another. One way to model this in an object-oriented fashion is to create an Account entity that allows us to withdraw money from a source account and deposit it into a target account:
The Account entity provides the current snapshot of an actual account. Every withdrawal from and deposit to an account is captured in an Activity entity. Since it would not be wise to always load all activities of an account into memory, the Account entity only holds a window of the last few days or weeks of activities, captured in the ActivityWindow value object.
To still be able to calculate the current account balance, the Account entity additionally has the baselineBalance attribute, representing the balance the account had just before the first activity of the activity window. The total balance, then, is the baseline balance plus the balance of all activities in the...