开发者

DDD - Identifying entities, roots and services

开发者 https://www.devze.com 2022-12-26 10:26 出处:网络
I want to apologize for my bad english first. I am trying to implement DDD in my project, but I have some problems I will try to describe. I am developing a chat application. Front-end is quite simple

I want to apologize for my bad english first. I am trying to implement DDD in my project, but I have some problems I will try to describe. I am developing a chat application. Front-end is quite simple, no rooms, just one window showing last n messages.

  1. Here comes the first problem. I don't see any entity here (ChatRoom would be ok, but I have only one room). Message seems like value object to me. So I don't know how to save state of chat (I think that having repositories for value objects is a bad practice).

This chat should have one specific feature, it should group and store related messages together (create something like ChatSegment). These segments will be divided by blocks of m off-topic messages (off-topic messages mean messag开发者_运维百科es unrelated to messages in current segment).

  1. I cannot imagine the way to make this work, without using stateful service. This behavior does not fit into any Entity (not even into the hypothetical ChatRoom entity). Segmenter entity does not seem right either. How would you solve this problem?

Maybe my thoughts are totally incorrect, but I would need to make them clear. Thank you,

Brano.


In an IM application I'd (OTTOMH) treat Meassage as an Entity with a unique Id.

Combining DDD with DNC could be very powerful here if you treat your Message type as a «moment» archetype, and perhaps also use «role» archetypes (e.g. Chatter) in order for the users of the system to take on more than one «role» of needed.

Furthermore; the concept of "next/prior moment (i.e. message)" seems to be a perfect match.

0

精彩评论

暂无评论...
验证码 换一张
取 消