“使用”和“使用”有什么区别?和“取决于”?
In this beginners guide to Dependency Injection I noticed that the UML diagram distinguishes between "uses" and "depends upon".
Since both require some form of a reference in the class that "uses" or "depends upon", I wonder: What is really the difference between the two?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看取自 IBM Rational Software Architect 文档。
“取决于”的含义如下:
“使用”的含义如下:
正如我所读到的,“用法”是一种不太严格的“依赖关系”。
Check out the blockquotes about relationship types taken from IBM Rational Software Architect documentation.
"depends upon" means the following:
"uses" means the following:
As I read it "usage" is a less strict "dependency".
请注意,我已经说过“类”,但它同样适用于“接口”。
维基百科对此有一篇很好的文章: http://en.wikipedia.org/wiki/ Dependency_%28UML%29
因此,例如,您可以在类驱动程序和接口 IVehicle 之间建立使用关系,该关系公开一个名为 Drive() 的方法。对 Drive 实现的更改不需要对 Driver 进行任何更改,因此您说 Driver 使用 IVehicle。
然而,类驱动程序对类手有依赖关系,因为驱动程序有两个属性:手左手和手右手。如果这些的实现发生变化,则需要考虑驱动程序是否需要相应更新。
Note I've said Class, but it applies equally to Interfaces.
Wikipedia has a good article on this: http://en.wikipedia.org/wiki/Dependency_%28UML%29
So for example you could have a Uses relationship between a Class Driver and an Interface IVehicle which exposes a method called Drive(). Changes to the implementation of Drive do not require any changes to Driver, so you say Driver uses IVehicle.
However Class Driver has a Dependency on Class Hand, since Driver has two properties: Hand LeftHand and Hand RightHand. If the implementation of these changed, one would need to consider if Driver needed updating accordingly.