用户聊天消息应该是聚合的吗?
Should user chat message be an aggregate?
在为典型的聊天应用程序(无限聊天)建模时,是否应将每条消息视为聚合实例?
聚合应该保持小,并且不能想到一些其他像样的小候选来包含用户消息。但与此同时,我也想知道我应该为系统这么小的对象使用聚合概念。
should each message be treated as an aggregate instance?
这是一个很好的问题,但问错了一群人,因为我们不了解您的业务:)
Aggregate is a synonym for the boundary of a transactional
consistency. [...] Properly designed Aggregate is the one, that can be
modified in the way business needs to modify it, while providing
business rules to be consistent as part of a single transaction. [...]
Aggregates are mostly about consistency boundaries, and their design
should not controlled by the need to create object graphs. [...] ~ Implementing Domain-Driven Design, Vaughn Vernon
聚合主要是关于业务规则中事务的一致性。您应该询问业务是否有关于单个聊天消息的任何规则。在典型的聊天应用程序中可能不会,但您必须询问业务。
在我能想象的最简单 聊天应用程序中,my 聊天消息更像是一个值对象。或者我 甚至不会像 Tseng 提到的那样使用 DDD。我想不出我需要的任何业务规则,而且它肯定是不可变的。
在为典型的聊天应用程序(无限聊天)建模时,是否应将每条消息视为聚合实例?
聚合应该保持小,并且不能想到一些其他像样的小候选来包含用户消息。但与此同时,我也想知道我应该为系统这么小的对象使用聚合概念。
should each message be treated as an aggregate instance?
这是一个很好的问题,但问错了一群人,因为我们不了解您的业务:)
Aggregate is a synonym for the boundary of a transactional consistency. [...] Properly designed Aggregate is the one, that can be modified in the way business needs to modify it, while providing business rules to be consistent as part of a single transaction. [...] Aggregates are mostly about consistency boundaries, and their design should not controlled by the need to create object graphs. [...] ~ Implementing Domain-Driven Design, Vaughn Vernon
聚合主要是关于业务规则中事务的一致性。您应该询问业务是否有关于单个聊天消息的任何规则。在典型的聊天应用程序中可能不会,但您必须询问业务。
在我能想象的最简单 聊天应用程序中,my 聊天消息更像是一个值对象。或者我 甚至不会像 Tseng 提到的那样使用 DDD。我想不出我需要的任何业务规则,而且它肯定是不可变的。