DDD:关于存储库/域边界的混乱 [英] DDD: Confusion about repository/domain boundaries

查看:83
本文介绍了DDD:关于存储库/域边界的混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的域由产品,部门,类,制造商,DailySales和HourlySales组成。

My domain consists of Products, Departments, Classes, Manufacturers, DailySales, HourlySales.

我有一个ProductRepository,可以方便地从存储中存储/检索产品。

I have a ProductRepository which facilitates storing/retrieving products from storage.

我有一个DepartmentAndClass存储库,它可以方便地存储/检索部门和类,以及从这些部门和类中添加和删除产品。

I have a DepartmentAndClass repository which facilitates storing/retrieving of departments and classes, as well as adding and removing products from those departments and classes.

我还有一个DailySales存储库,可用于从多个分组检索有关每日销售额的统计信息。即

I also have a DailySales repository which I use to retrieve statistics about daily sales from multiple groupings. ie..

DailySales.GetSalesByDepartment(dateTime)
DailySales.GetSalesByClass(dateTime)
DailySales.GetSalesByHour(dateTime)

像这样在自己的存储库中使用这些销售跟踪方法是否正确?我在正确的轨道上吗?

Is it correct to have these sales tracking methods in their own repository like this? Am I on the right track?

推荐答案

由于域是如此依赖上下文,因此某些答案比其他答案难。但是,我会将统计信息放在 Query 方面。您可能不希望即时计算这些统计信息,因为您将对数据库进行大量处理。通常,应该对统计信息进行非规范化,以便在仅需要过滤的情况下进行快速访问。

Since domains are so dependent on context some answers are harder than others. I would, however, place statistics on the Query side of things. You probably do not want to be calculating those stats on the fly as you will be placing some heavy processing on your database. Typically the stats should be denormalized for quick access where only filtering is required.

如果您尚未这样做,则可能要看一下CQRS。

You may want to take a look at CQRS if you haven't done so.

这篇关于DDD:关于存储库/域边界的混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆