领域驱动设计问题

发布于 2024-07-11 04:02:19 字数 272 浏览 4 评论 0原文

我想询问一个推荐的解决方案: 我们有一份比赛清单。 每场比赛都有明确的参赛者必须支付的费用 我们有参与者 我必须知道参加比赛的参赛者是否已支付费用。 我正在考虑两种解决方案,问题是它必须是领域驱动设计中最合适的解决方案。 首先是在竞赛中创建字典而不是列表,字典的类型为。 第二个可能是创建一个不同的类,它有两个字段:参与者和费用。 在竞赛中,我将获得该新类的对象列表。

谢谢

I would like to ask for a reccomended solution for this:

We have a list of Competitions.

Each competition has defined fee that a participatior has to pay

We have Participators

I have to know has a Participator that is on a Competition paid the fee or not. I am thinking about 2 solutions and the thing is it has to be the most appropriate solution in Domain Driven Design.
First is to create a Dictionary in Competition instead of a List, the dictionary would have be of type <Participator, bool>.
The secont is perhaps create a different class that has 2 fields, a participator and feePaid. And in Competiton I would have a list of object of that new class.

Thank you

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

予囚 2024-07-18 04:02:19

听起来像是典型的多对多关系。 我将使用 Entry 关联类对其进行建模,如下所示:

class Participator {
}
class Competition {
    Currency fee
}
class Entry {
    Competition competition
    Participator participator
    Boolean feePaid
}

sounds like a typical many to many relationship. i would model it with an Entry association class as follows:

class Participator {
}
class Competition {
    Currency fee
}
class Entry {
    Competition competition
    Participator participator
    Boolean feePaid
}
明月松间行 2024-07-18 04:02:19

我处理这个问题的方法是举办竞赛、参与者和注册。 参赛者将注册参加比赛,创建一个注册。 注册将包含竞赛 ID、参与者 ID、指示是否支付费用的标志以及任何其他注册特定数据(例如注册日期)。 这将在数​​据库中建模为“连接表”(带有附加数据)。 在应用程序方面,参与者将有一个注册列表,每个注册都会有一个关联的参与者和一场比赛。 同样,每个比赛都会有一个注册列表。

The way I would handle this is to have Competitions, Participants, and Registrations. A Participant would register for a Competition, creating a Registration. A Registration would consist of the Competition id, Participant id, a flag indicating whether the fee was paid or not, and any other registration-specific data (like the date of registration). This would be modeled in the database as a "join table" (with the additional data). On the app side, a Participant would have a list of Registrations, each Registration would have an associated Participant and a Competition. Likewise, each Competition would have a list of Registrations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文