【问题标题】:Do you include the constructors in a uml class diagram as methods? [duplicate]您是否将 uml 类图中的构造函数作为方法包含在内? [复制]
【发布时间】:2019-07-31 11:57:21
【问题描述】:

我正在做一个uml 类图。

我有一个类,我有变量和多个构造函数。 那些要包含在uml 类图中吗?

如果是,

这样好吗?

<<constructor>> Cells()
<<constructor>> Cells(int)?

【问题讨论】:

    标签: class constructor uml diagram


    【解决方案1】:

    视情况而定。

    有时不显示,有时显示为常规方法,有时显式显示为特殊功能。

    刻板印象和注释是你的朋友。

    ..........................................................
    ..........................................................
    ......+----------------------------------------+---+......
    ......|........................................|...|......
    ......|..This is the default constructor.......+---*---+..
    ......|............................................|...|..
    ......+--------------------------------------------+...|..
    .......................................................|..
    .......................................................|..
    ..+-------------------------------------------------+..|..
    ..|...............<<..class..>>.....................|..|..
    ..|.................MyVideoGame.....................|..|..
    ..+-------------------------------------------------+..|..
    ..|..+....MyVideoGame( )...........<<constructor>>..*--+..
    ..|..+.... MyVideoGame (int this)..<<constructor>>..|.....
    ..+-------------------------------------------------+.....
    ..|..+....~MyVideoGame( )...........<<destructor>>..*--+..
    ..+-------------------------------------------------+..|..
    .......................................................|..
    .......................................................|..
    .......+-----------------------------------------+-----+..
    .......|.........................................|.....|..
    .......|..This is the default destructor.........+-----*..
    .......|...............................................|..
    .......+-----------------------------------------------+..
    ..........................................................
    ..........................................................
    

    请注意,我使用“c++”风格的构造函数和析构函数,但也适用于另一个 P.L.

    U.M.L.让您可以根据项目要求灵活地显示模型。

    请忽略多余的点,用于格式化图表。

    【讨论】:

    • 很高兴看到一个 UML 的粉丝,但是 UML 什么时候写成 U.M.L.?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-29
    • 1970-01-01
    • 1970-01-01
    • 2017-08-17
    • 1970-01-01
    • 2015-06-15
    相关资源
    最近更新 更多