How do I formally document a C# Attribute in UML?

跟風遠走 提交于 2019-12-11 01:25:55

问题


What is the proper way to document a C# Attribute on a class in a UML class diagram?


回答1:


I haven't decided if this is my answer, but I figured I'd throw it out there for sake of discussion. Does this look acceptable?

Its an instance of the attribute type with the metadata values put into tagged values below. I just figured out how to add custom stereo types. The arrow is just a dependency arrow that is labeled as "applies".




回答2:


I don't know if this is "standard", except that it uses a standard feature from UML:

Sparx Enterprise Architect, when reverse-engineering, for instance, a unit test class, uses tagged values for the attributes. A tagged value "Attribute" on the class, has the name of the attribute as a value, for instance, "[TestClass]". Similarly, "Attribute = [TestMethod]" is placed on the methods. An example would be:

[TestClass]
public class MyTests
{
    [TestMethod]
    public void DoSomeTest()
    {
    }
}

In this example, [TestClass] and [TestMethod] are .NET attributes (not UML attributes). They are short for [TestClassAttribute] and [TestMethodAttribute]. Both are classes deriving from the System.Attribute class.

An attribute simply adds metadata to the assembly. By itself, it has no runtime behavior.



来源:https://stackoverflow.com/questions/4765992/how-do-i-formally-document-a-c-sharp-attribute-in-uml

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