gpt4 book ai didi

php - 实时通知 UML 类图

转载 作者:IT王子 更新时间:2023-10-28 23:44:14 25 4
gpt4 key购买 nike

我正在尝试实现一个实时通知系统(例如 fb、xing、twitter..)。因此,我在构建实体之前创建了一个 UML 类图。展示如下:


EDIT: I Thought about this approach and it seems as if this is not the right one. Let's check the following scenarion: User U adds at Event E's image I a comment C. How to store this correctly, I mean EventNotification only has a reference on the Event E, but not on I and C. Therefore I would need to create an "EventImageNotification" class as well and this would be a mess. Would it be a nicer solution to just have one "Notification" class and add a "metadata" field to it, which stores references to all involved fields?


(稍后我将使用 OR-Mapper 来实现关系)。

[ 1 ] 一个用户可以创建事件,例如“2015 年西尔维斯特派对”。 (一对多)。此事件有一个仪表板,用户可以在其中订阅以在创建者在该事件上发布内容时接收更新 (ManyToMany)。

[ 2 ] 当用户在事件的仪表板上发布内容时,订阅用户应该会收到通知。因此,我创建了 EventNotification 类。用户和 EventNotification 之间的关系是多对多的。

[ 3 ] 为了保持简洁,我创建了一个与 Notification 类型相关的 AbstractNotification 类。通知类型类似于 name = "EventPost"和 template = "User user has posted something new on event __event"。

[ 4 ] 抽象类NotificationConnector给EventNotification和User(UserEventNotification)之间的映射类赋予字段。我创建它们是为了在将来轻松扩展它,例如用户可以创建也会触发事件等的书籍。然后我需要创建一个“BookNotification”和一个“UserBookNotification”类来存储这个新实体的通知。

这种方法是好的还是一团糟?请告诉我您对此图的看法:

(建立联想的箭头应该是普通线,我用的工具做不到)

Notification UML

最佳答案

只是一些观察:

  • 这两个抽象类似乎是多余的,因为您只在一个上下文中使用它们。
  • has来自 User 的连接应该去 UserEndNotification而不是抽象类(无论如何我建议放弃)。
  • 我会做 NotificationType一个<<enumeration>>
  • 而不是使用 owns关系 我会在 User 之间使用关联类和 Event并添加 isOwnerisSubscriber属性(property)。

关于php - 实时通知 UML 类图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33103332/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com