4

I am new at domain driven design. We are creating entity objects to represent our model. And Representing database tables with same schema. But I am a bit confused about summary objects.

Product is an entity and database table. States is an entity and databse table.

I want to get a summary list like this:

StateName     ProductName      SellCount
---------------------------------------
State-1       Laptop-ESD14     145
State-1       IPhone-FMNL8     1220
State-1       Book-OYLG4       7789

This is a statistics object, actually this is a relational select query result. Where can I store this object. Is this an Entity or Value or ViewModel?

If this is a view model I can not store it in Domain layer, I can store in Application Layer. In this stuation how can I get this object from database? (Also I am using ORM tools like Entity Framework)

barteloma
  • 6,403
  • 14
  • 79
  • 173

2 Answers2

3

Is this an Entity or Value or ViewModel?

ViewModel isn't a DDD related term, but if it's readonly, it seems like this could be a Read Model. From there you can write a simple specialized "reporting" Repository for it, or go the full CQRS route.

guillaume31
  • 13,738
  • 1
  • 32
  • 51
2

There is no such thing as statistics objects in DDD. You really should drop all implementation details like which tables to create etc until your entire domain model is complete.

From DDD's perspective it doesn't matter if an object is loaded using a complex join etc, it's still just an entity or a value object.

In DDD we use the repository pattern just to be able to abstract away those details and just focusing on building a domain model which represents our stakeholders wishes and language.

jgauffin
  • 99,844
  • 45
  • 235
  • 372
  • My summary statistics view model is named SaleSummaryView. So, is SaleSummaryView a value object? – barteloma Mar 02 '15 at 11:52
  • 1
    @bookmarker: Only you can answer that. The definition of value objects: `An object that contains attributes but has no conceptual identity. They should be treated as immutable` – jgauffin Mar 02 '15 at 15:07