在 UML 类图中表示 C# 访问器属性? [英] Representing a C# accessor property in a UML Class Diagram?

查看:99
本文介绍了在 UML 类图中表示 C# 访问器属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 UML 类图中表示 C# 属性(setter 和 getter 访问器)?

你只是把它写成常规的 setter 和 getter 方法吗?

或者有其他的表示方式吗?

我对如何在 UML 类图中的类和接口中表示访问器感兴趣.

解决方案

一些开发人员/分析师:

(1) 将属性显示为一个非常概念化的东西,并且每个属性只显示一行.

(2) 其他,比较具体,显示3行,属性,getter"函数,setter"函数.

(3) 有时,只显示 2,用于附件.

(4) 一些 U.M.L.绘图应用程序.允许您选择要显示哪个先验.

还有……

...据我调查,所有选项都是正确的.请记住,刻板印象(<<some stuff>>",可以帮助记录课程.

(注意:我用点代替空格)

(1) 只有普通属性(C#,非常概念化):

<预>+==================================================================+|................................我的课堂......................…………|+----------------------------------------------------------------+|..[+]..|..void....|..MyClass()...|..<<构造函数>>.................||..[+]..|..void....|..~MyClass()..|..<<析构函数>>........|+==================================================================+|..[+]..|..string..|..Text........|..<<属性>>...........|+==================================================================+

(2) 只有附件",(C++、Java、样式):

<预>+==================================================================+|................................我的课堂......................…………|+----------------------------------------------------------------+|..[+]..|..void....|..MyClass()...|..<>........||..[+]..|..void....|..~MyClass()..|..<<析构函数>>........|+==================================================================+|..[#]..|..string..|..FText.......|..<<字段>>.....................................|+==================================================================+|..[+]..|..string..|..getText()...|..<<function>>,..<<getter>>...|+----------------------------------------------------------------+|..[+]..|..string..|..setText()...|..<<procedure>>,..<<setter>>..|+==================================================================+

(2) 一切(非常程序员,Object Pascal/Delphi 风格):

<预>+==================================================================+|................................我的课堂......................…………|+----------------------------------------------------------------+|..[+]..|..void....|..MyClass()...|..<<构造函数>>.................||..[+]..|..void....|..~MyClass()..|..<<析构函数>>........|+==================================================================+|..[#]..|..string..|..FText.......|..<<字段>>.....................................|+==================================================================+|..[+]..|..string..|..Text........|..<<属性>>...........|+----------------------------------------------------------------+|..[+]..|..string..|..getText()...|..<<function>>,..<<getter>>...|+----------------------------------------------------------------+|..[+]..|..string..|..setText()...|..<<procedure>>,..<<setter>>..|+==================================================================+

您正在向分析师提供服务吗?您的 C++/Java 程序员是否知道,如果图表仅显示属性,他们必须对附件进行编码,或者您的公司要求在图表中明确声明它们?

选择最适合您的需求.(删除点).

How does one represent a C# property (setter and getter accessors) in a UML Class diagram?

Do you just write it as regular setter and getter methods?

Or is there some other way of representing it?

I'm interested in how accessors are represented in a class and interface in a UML Class diagram.

解决方案

Some developers / analysts:

(1) show properties as a very conceptual thing, and only show a single row per property.

(2) Others, are more specific, and display 3 rows, the property, the "getter" function, the "setter" function.

(3) And sometimes, only show 2, for the accesors.

(4) Some U.M.L. drawing apps. allows you to select which of the prior, do you want to display.

And...

...As far as I have investigated, all options are right. Remember, that stereotypes ("<<some stuff>>", are allowed to help document the class.

(Note: I replace spaces by dots)

(1) Only plain property (C#, very conceptual):

+================================================================+
|..........................MyClass...............................|
+----------------------------------------------------------------+
|..[+]..|..void....|..MyClass()...|..<<constructor>>.............|
|..[+]..|..void....|..~MyClass()..|..<<destructor>>..............|
+================================================================+
|..[+]..|..string..|..Text........|..<<property>>................|
+================================================================+

(2) Only "accesors", (C++, Java, style):

+================================================================+
|..........................MyClass...............................|
+----------------------------------------------------------------+
|..[+]..|..void....|..MyClass()...|..<<constructor>>.............|
|..[+]..|..void....|..~MyClass()..|..<<destructor>>..............|
+================================================================+
|..[#]..|..string..|..FText.......|..<<field>>...................|
+================================================================+
|..[+]..|..string..|..getText()...|..<<function>>,..<<getter>>...|
+----------------------------------------------------------------+
|..[+]..|..string..|..setText()...|..<<procedure>>,..<<setter>>..|
+================================================================+

(2) Everything (Very Programmer, Object Pascal / Delphi style):

+================================================================+
|..........................MyClass...............................|
+----------------------------------------------------------------+
|..[+]..|..void....|..MyClass()...|..<<constructor>>.............|
|..[+]..|..void....|..~MyClass()..|..<<destructor>>..............|
+================================================================+
|..[#]..|..string..|..FText.......|..<<field>>...................|
+================================================================+
|..[+]..|..string..|..Text........|..<<property>>................|
+----------------------------------------------------------------+
|..[+]..|..string..|..getText()...|..<<function>>,..<<getter>>...|
+----------------------------------------------------------------+
|..[+]..|..string..|..setText()...|..<<procedure>>,..<<setter>>..|
+================================================================+

Are you delivering to analysts ? Does your C++ / Java programmers know that if the diagram shows only properties, they have to code the acccesors, or your company requires to explicity declared them in the diagrams ?

Choose the one that fits more your needs. (remove dots).

这篇关于在 UML 类图中表示 C# 访问器属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆