Showing the Dependency Relationship on a Visual Studio class diagram

南笙酒味 提交于 2019-12-08 06:19:27

问题


Say I have a class structure like this:

public interface IFoo
{
}

public class Foo : IFoo
{
}

public class Bar
{
    public void Test(IFoo foo)
}

Is it possible to show an association relationship between Foo and Bar (the weakest relationship). Should I even be doing this?


回答1:


As @Thomas Kilian said your relationship (between Bar and IFoo) is not any types of Association. It can be Dependency relationship.

To have more explaination about Dependency Relationship:
Dependency Relationship is one of UML relationships and it stand on top of other type dependencies.

Your dependency is type of Usage: use Dependency. (see reference 1)

For example, it could mean that some method(s) within a (client) class uses objects (e.g. parameters) of the another (supplier) class.



Unfortunately, Class Designer of Visual Studio, ONLY shows Inheritance and Association.

If we want to explain the idea:
Dependency Relationship did not show remarkable things between classes. There are many types of Dependencies (see reference 1 and reference 2) and if Class Designer wants to show each type of relationship, our diagrams will be so messy.

In the other hand, Dependency Relationship mostly use in Requirement and Analysis phase of Methodologies. (not mostly in implementation)

For this reason, if you reverse engineer your code to have Class Diagram of your code in CASE Tools (like Enterprise Architect), the dependency relationship will not draw by the CASE Tools.




回答2:


You will show a dependency, which is the weakest form. And you draw it to the interface like this:



来源:https://stackoverflow.com/questions/47923225/showing-the-dependency-relationship-on-a-visual-studio-class-diagram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!