历史关联模式

发布于 2025-01-10 04:42:45 字数 282 浏览 0 评论 0原文

我目前正在研究软件工程模式,我们被要求研究的一个模式是“历史关联模式”,它指的是福勒的“分析模式”书中给出的历史映射模式。我们给出的示例如下:

在此处输入图像描述

我尝试在线查找有关如何实现此结构的信息,但没有找到任何有关历史地图关联的信息。该结构的代码/伪代码示例是什么?

I'm currently studying software engineering patterns and one that we've been given to study is the "historical association pattern" It refers to the historical mapping pattern given in Fowler's "Analysis patterns" book. The example we've been given is as follows:

enter image description here

I've tried looking for information online on how this structure would be implemented but I've found nothing regarding historical mapping associations. What would be a code/pseudo-code example of this structure?

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

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

发布评论

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

评论(1

淡淡の花香 2025-01-17 04:42:45

简短回答

此模式仅包括通过关联类将一些日期用于关联。

完整解释

中间的菱形是员工、日期和金钱之间的三元关联。虚线表示 Salary 是关联类,它也与 Date 关联。

关联类通常使用 Employee、Date、Money 和 Salary 属性的元组/组合类来实现。完成的方式可能非常不同:在 Java 中,您将直接引用关联的对象,而在数据库中,您将混合使用 ids 和工资属性。比这个令人印象深刻的图表简单得多。

有更简单的模型!

该图难以阅读(三元关联)、难以理解(三元关联中的多重性并不明显难以掌握)、不明确(即 Salary 与两个日期相关联,来自它代表的三元关联和直接关联?或者是它只是图形冗余?)。

如果将其重构为二元关联,以及将诸如 Dare 之类的值对象显示为属性,那么理解起来就会容易得多。

Short answer

This pattern consist simply of using some dates for an association, by the means of an association class.

Full explanation

The diamond in the middle is a ternary association between Employee, Date and Money. The dotted line says that the Salary is the association class and it is also associated with a Date.

The association class would be typically be implemented with tuples/composed classes of Employee, Date, Money and the Salary attributes. The way it is done can be very different: in Java you’d directly refer to the associated objects, whereas in a db you’d have a mix of ids and salary attributes. Much simpler than this impressive diagram.

There are simpler models for that!

This diagram is difficult to read (ternary association), difficult to understand (multiplicity in ternary associations are not obvious to grasp), ambiguous (i.e. is Salary associated with two dates, from the ternary association it represents and from the direct association? or is it just a graphical redundancy?).

It would be much simpler to understand if it would be refactored into a binary association, and if value objects such as Dare would be shown as attributes.

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