Align DDD, view modes and performance

I'm starting to learn about DDD and worry about the performance implications for extracting object objects from persistence and then restructuring them in view mode for the user interface.

Let's say that I have two cumulative roots:

Person      Orders
------      -------
personId    orderId
name        personId

Each consolidated root has its own repository responsible for the basic CRUD operations for the entire aggregate.

Let's say that the following columns are required for the user interface:

viewmodel
---------
personName
numberOfOrders

I can imagine two ways in which I can populate this view model:

  • Eagerly load all human entities, eagerly load all orders based on personId, restructure the loaded objects in the viewmodel.
  • JOIN/COUNT (orderId) , .

, 1 , , . 2 .

2 () , " " " ?"? " " , ? - , DDD ?

, DDD , ?

/

, - /. , , , . .

+5
2

, :

// value object
class PersonStatistics {
    String PersonName
    Int NumberOfOrders
    Money AverageOrderAmount
}

// repository
interface PersonStatisticsProvider {
    PersonStatistics Get();
}

read-model.

+5

2, , , , , , .

OrderRepository.GetOrderCountByPerson(personId), .

ViewModels . , , , ViewModel.

0

All Articles