how to write data attributes in UML with typedef unsigned

独自空忆成欢 提交于 2019-12-25 04:28:49

问题


this is my sample code my question is how am i going to write uint delay in UML Class Diagram, because it is typedef unsigned -----------------------------------------------------------------------------------------should i write it like this? - delay : int or this way? - delay : uint ---------------------------------------

typedef unsigned int uint; 

class MyBreakoutGameType : ...
{
public:

private:
     uint delay;
};

回答1:


Your diagram for the mentioned code should look like




回答2:


Version 13.5 of Enterprise Architect does import typedefs as classes with «typedef» stereotype. The original type is then referred to by generalization. This way the information of the underlying type does not get lost.

In case the «typedef» stereotype is undefined (and shall not be added to the used profile) you may use an ordinary class which has an «import» relation to the original type.

This answer suggests to use only the «import» relation specifying the name of the alias on the connector. I do not prefer that solution as the alias can then not be referred to.




回答3:


UML has a few predefined primitive types, e.g. "Integer", but "int" is not a predefined primitive type in UML. New primitive types can be modeled using a classifier with the «primitive» keyword (UML 2.5 spec, section 10.2.5). To specify the corresponding C++ data type, you may wish to add a note:

Then, you may using this primitive data type as the data type of an attribute, like this:

Of course, this makes the class dependant on the existence of the «primitive» uint. You may stress this dependency by drawing a dashed arrow from MyBreakoutGameType to uint, but this is optional.



来源:https://stackoverflow.com/questions/39604917/how-to-write-data-attributes-in-uml-with-typedef-unsigned

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