concept Account in category system administration

appears as: Account, Account, An Account, n Account
Functional and Reactive Domain Modeling

This is an excerpt from Manning's book Functional and Reactive Domain Modeling.

Figure 1.4. Relationships between the domain elements of a model. This example is from the personal banking domain. Note that Account, Bank, and so forth are entities. An entity can contain other entities or value objects. A service is at a higher level of granularity and implements behaviors that involve multiple domain elements.
  • Participation in behaviors— How the object is represented in memory when it interacts within the system. This is the way you model an entity or a value object within your system. A complex entity may consist of other entities as well as value objects. As an example, in figure 1.4, an Account entity may have references to other entities such as Bank or other value objects such as Address or Account Type.
  • Persistence— How the object is maintained in the persistent form. This includes issues such as how you write the element to the persistent storage; how you retrieve the details in response to queries by the system; and if your persistent form is the relational database, how you insert, update, delete, or query an entity such as Account.
  • Listing 1.2 shows the design of an Account aggregate in Scala. It consists of the aggregate root Account (which is also an entity), and has entities such as Bank and value objects such as Address as part of its composing elements.[3] Designing aggregates isn’t an easy task, especially if you’re a beginner in DDD. Besides Eric Evans’ Domain-Driven Design book, take a look at the “Effective Aggregate Design” article from Vaughn Vernon that discusses in three parts the various considerations that you need to make to design a good aggregate (http://dddcommunity.org/library/vernon_2011/).

    3In reality, when you design aggregates, you may find that for performance and consistency of operations you have to optimize away many composing entities from the aggregate and have only the root along with the value objects. For example, you may choose to keep a bank ID instead of the entire Bank entity as part of the Account aggregate.

    Listing 1.2. Account as an aggregate
    case class SavingsAccount( //.. rateOfInterest: BigDecimal, //.. ) extends Account trait AccountService { def transfer(from: Account, to: Account, amount: Amount): Option[Amount] }