UML 类图 关系类型

发布于 2024-07-15 04:36:05 字数 578 浏览 7 评论 0原文

我有两个类,但不知道我应该使用哪种关系。 我有一个类 Document,它有很多属性但没有方法。 第二类是我所说的DocumentFact(事实-工厂)。 此类包含返回 Document 对象集合的不同方法。

因此,Document 类对 DocumentFact 类一无所知,因为它与之无关。 另一方面,DocumentFact 创建多个 Document 对象。 这是一种什么样的UML关系? 我在想这样的事情:

--------------           ------------
|DocumentFact|  -------> | Document |
--------------       2.* ------------  

或者:

--------------            ------------
|DocumentFact|  ------- []| Document |         // Composition
--------------            ------------  

你觉得怎么样?

I have two classes, but don't what kind of relation i should use. I have a class Document with a lot properties and no methods. The second class is what i called the DocumentFact (Fact - Factory). This class contains different methods which returns a collection of Document objects.

So, the Document class doesn't know anything about the DocumentFact class because it has nothing to do with it. On the other hand, DocumentFact creates multiple Document objects. What kind of UML relation is this? I was thinking something like this:

--------------           ------------
|DocumentFact|  -------> | Document |
--------------       2.* ------------  

Or:

--------------            ------------
|DocumentFact|  ------- []| Document |         // Composition
--------------            ------------  

What do you think?

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

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

发布评论

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

评论(3

暗藏城府 2024-07-22 04:36:05

只是我的意见 - 如果 DocumentFact 真的是一个工厂,我会花费额外的三个按键并将其拼写出来。 当您的类的用户第一次阅读类名时,您迫使他们弄清楚您的意思是“文档工厂”还是“有关文档的事实”。 这种不确定性是不必要的,特别是如果你可以盲打的话。 我建议使名称更加自记录并且不那么含糊。

Just my opinion - if DocumentFact truly is a Factory, I'd spend the extra three keystrokes and spell it out. You force users of your class to figure out whether you mean "document factory" or "fact about a document" when they read the class name for the first time. The uncertainty is unnecessary, especially if you can touch type. I'd recommend making the name more self-documenting and less ambiguous.

空宴 2024-07-22 04:36:05

我同意工具包的观点,工厂 - >产品是一种实例化关系 - 多重描述符不适用,除非工厂也打算维护对产品对象的引用,在这种情况下它是 1:* 或 1:n (多吨)反正

I agree with toolkit that factories->product is an instantiates relationship - the multiplicity descriptor doesn't apply unless the factory is also intended to maintain references to the product objects in which case it's a 1:* or 1:n (multiton) anyway

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