UML 类图中的接口聚合
人们通常会在接口之间放置聚合关联吗?
示例:
在这里,我觉得一个聚合是多余的。接口之间的接口更为重要,因为这是类的客户端将使用的接口。 BMW 和 LuxuryWheel 将始终通过 ICar 和 IWheel 使用。然而,ICar 并没有真正聚合 IWheel,因为它只是一个接口,不包含实际逻辑。宝马确实明确聚合了 LuxuryWheel,但这几乎是一个实施细节。
你会如何建模? UML 中有没有一种方法可以将聚合(或关联)标记为抽象或待实现?
does one usually put aggregating associations between interfaces?
Example:
Here, I feel that one aggregation is redundant. The one between the interfaces is more important, because that's what the clients of the classes will be using. BMW and LuxuryWheel will always be used through ICar and IWheel. However, ICar does not really aggregate IWheel, as it is an interface and contains no actual logic. BMW does clearly aggregate LuxuryWheel but that is almost an implementation detail.
How would you model this? Is there a way in UML to mark an aggregation (or association) as abstract, or to-be-implemented?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看 UML 规范,您会发现7.3.24:
所以,是的,您可以在接口之间绘制聚合,但您的图表可能并不完全符合您的预期。
If you look at the UML spec, you'll find that in 7.3.24:
So, yes, you can draw aggregations between interfaces, but your diagram may not exactly mean what you expect.