有没有一种方法来避免这种钻石问题这种设计

发布于 2025-02-04 21:11:47 字数 982 浏览 3 评论 0原文

我有一个事件处理用例,在事件处理过程中,我将模板用于涉及的各种逻辑,例如交易处理,基于事件的处理模板,例如更新,插入等。但是,还存在一些关于具体实现的常见处理逻辑目前正在造成钻石问题。有更好的方法来建模吗?

AbstractEventProcessing (batch processing, txn handling etc with construction deps)
^
|
|-------|------------------------------| 
|       UpdateEventProcessing          InsertEventProcessing
|       (template for processing, no construction deps)
|
|----------------------------|
AbstractEvent1Processor      AbstractEvent2Processor
(parsing for event1 etc.)    ...
constrcution deps            ^
^                            |
|                            ConceretUpdateEvent2Processor
|                            (needs UpdateEventProcessing) 
|
|-------------------------------|           
ConcreteUpdateEvent1Processor   ConcreteInsertEvent1Processor   
(needs UpdateEventProcessing)



但是,对于所有事件处理器的更新和插入,该模板是相同的,这些事件处理器导致具有2个基类的问题(AbstractEvent1Processor& UpdateEventProcessing)。还有其他一些建模方法吗?另外,由于这些模板在许多具体实现中都使用了如何在不同地方重复测试相同的东西

I have an event processing use case where I am using templates for various kinds of logic involved during event processing e.g transaction handling, processing template based on events e.g update, insert, etc. however, there is some common processing logic on concrete implementation as well which is currently creating diamond problems. Is there a better way to model them?

AbstractEventProcessing (batch processing, txn handling etc with construction deps)
^
|
|-------|------------------------------| 
|       UpdateEventProcessing          InsertEventProcessing
|       (template for processing, no construction deps)
|
|----------------------------|
AbstractEvent1Processor      AbstractEvent2Processor
(parsing for event1 etc.)    ...
constrcution deps            ^
^                            |
|                            ConceretUpdateEvent2Processor
|                            (needs UpdateEventProcessing) 
|
|-------------------------------|           
ConcreteUpdateEvent1Processor   ConcreteInsertEvent1Processor   
(needs UpdateEventProcessing)



However, the template is the same for Update and Insert for all the Event processors which lead to problems of having 2 base class (AbstractEvent1Processor & UpdateEventProcessing). Is there are some other ways of modeling these? Also, since these templates are used in many concrete implementations how do not repeat testing the same things at different places

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文