简体   繁体   English

UML依赖关系

[英]UML Dependency relationship

Why and how are dependency relationships used? 为什么以及如何使用依赖关系?

I've come across a PiggyBank example where the Analysis Model consists of a class diagram with dependency relationships. 我遇到了一个PiggyBank示例 ,其中的分析模型由具有依赖关系的类图组成。

They use two relationships "use" and "instantiate" to describe the relationships between the classes. 他们使用“使用”和“实例化”两个关系来描述类之间的关系。

I don't agree with the relationship that the boundary class TransferMoneyForm has a "use" to the TranferMoneControl. 我不同意边界类TransferMoneyForm对TranferMoneControl有“使用”的关系。 I believe it should be the other way around. 我认为应该是相反的方式。

Can someone exaplain to me how these two relationships should be used. 有人可以向我说明如何使用这两种关系。 Thank you in advance. 先感谢您。

The diagram shown there is not a correct and full UML class diagram. 此处显示的图没有正确且完整的UML类图。 In such all the associations and generalizations should be defined, and what is abstract, what is public or not. 在这种情况下,应该定义所有关联和概括,什么是抽象的,什么是公共的。 To show what descends from what, what is hidden, what will be never instantiated and what fields of one class has types of other classes. 为了显示什么源自什么,隐藏什么,永远不会实例化什么以及一个类的哪些字段具有其他类的类型。 Here we see only information about the functions. 在这里,我们仅看到有关功能的信息。

And it is logical. 这是合乎逻辑的。 If you'll look at the previous chapter, there is written: "A control class represents a self-contained process..." So, they are talking on processes, not classes, instances and fields. 如果您看一下前一章,就会写道:“控件类代表一个自包含的过程……”因此,他们在谈论过程,而不是类,实例和字段。

It is NOT a class diagram. 它不是类图。 And nowhere is said that it is. 没有人说它是。 It is named "Transfer Money Participants diagram". 它被称为“转移资金参与者图”。 They do use the elements of the class diagram, but not to the fullest and so create something more common. 他们确实使用了类图的元素,但没有充分利用它们,因此创建了一些更常见的东西。 It is some approximate undefined diagram on some classes, something between class, communication or component diagrams. 它是某些类上的一些近似未定义图,类之间,通信图或组件图之间的某些图。 Maybe, it is the old style of IBM? 也许是IBM的旧风格? Experts ( What's the best UML diagramming tool? , 1st answer) say, "IBM Rational Software Architect did not implement UML 2.0". 专家( 最好的UML图表工具是什么? ,第一个答案)说:“ IBM Rational Software Architect没有实现UML 2.0”。 )

As for the question, who uses whom... According to Sparx VP UML, a "usage dependency" is a "relationship in which one element requires another element ... for its full functionality". 至于该问题,谁使用谁...根据Sparx VP UML,“使用依赖”是“一种关系,其中一个元素需要另一个元素……才能发挥其全部功能”。 According to wiki, "The client element somehow "uses" the supplier". 根据Wiki,“客户元素以某种方式“使用”供应商”。 Here the form hasn't sense without the controlling class, and vice versa. 在这种情况下,没有控制类是没有意义的,反之亦然。 So, I'd say, the use goes in both sides. 所以,我想说,用法是双向的。 But more honest would be to create a normal communication or component diagram. 但是更诚实的是创建一个普通的通信或组件图。 The class diagram has NOT an element to say about sending and accepting the messages. 类图没有关于发送和接受消息的元素。 And the "use" is definitely not for it. 而“使用”绝对不是它的目的。 And when they have decided not to use logic, they can put there virtually anything. 当他们决定不使用逻辑时,他们几乎可以放任何东西。

If you are making a class diagram and one your class uses function(s) of another one, that is the case to draw a use dependency connection. 如果要制作一个类图,而一个类使用另一个类的函数,则绘制使用依赖连接就是这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM