【发布时间】:2012-05-28 18:48:29
【问题描述】:
我正在构建一个新应用程序,并且是域驱动设计的新手。我一直在阅读文档,并设法对大部分领域模型进行建模,但我想对两个查询提出一些建议:
-
我有两个域对象通道和程序。我已经将它们建模为实体,因为它们都可以独立访问。一个频道可以有一个节目列表,所以我把它作为频道的一个属性。我的问题是我应该如何填充程序列表。 ChannelService中的getChannerById方法是否可以先获取频道信息,然后调用ProgramService获取频道的节目列表例如:
Channel { String channelId List <Program> programList } Program { String programId { } ChannelService { Channel getChannelById(String channelId) } ProgramService { Program getProgramById(String programId) List <Program> getProgramsByChannelById(String channelId) } -
我有一个产品域对象,但它的某些属性(例如规格和兼容性)涉及相当耗时的操作。这些属性并非一直都需要,因此可以将它们作为域对象的一部分并在需要时使用单独的服务方法填充这些属性,例如
Product { String productId Specification specification List <Product> compatibleProducts } ProductService { Product getProduct(String productId); void getProductSpecifications(Product product); void getCompatibleProducts(Product product); }
非常感谢任何建议。
【问题讨论】: