scala - 任何适用于 Scala 的 UML 工具

标签 scala uml

有没有可用于 Scala 的 UML 工具。我的问题的原因是它是函数式和 OO 概念的混合,因此我想知道这些工具如何在 UML 图中表示函数。

最佳答案

这个thread总结了任何想要表示 Scala 类的 UML 工具所面临的障碍:

  • there is no official representation of mixins in UML
  • it is difficult to represent:
    • closures
    • Scala type members
    • class constructor parameter bounds (a.k.a. "template type" bounds/constraints)
    • covariant and contravariant class constructor inheritance
    • the relationship between a class or trait and the companion object
<小时/>

这篇论文(“Evaluierung des Einsatzes von Scala bei der Entwicklung für die Android-Plattform ”,pdf,德语)确实添加了特征混合和其他 scala 特定元素的构造型(第 146 页)。

Meiko Rachimow 在 2009 年添加的内容:

属性、getter 和 setter

Scala attributes

For all published attributes exist implicit getter (attribute1 and attribute2), except the visibility was declared as private (attribute3). If published attributes are tagged with a stereotype Var, they are variables, for which there exist implicit setter (attribute2). The stereotype lazy marks instance variables as lazy (attribute4).

类和泛型

Scala class and genericity

Like in UML, generic classes are marked with an abstract type. By using the Scala language syntax, upper and lower bounds can be declared for this type (EineKlasse). It is possible to use structured types as bounds, which attributes and methods are embraced by curly braces (EineKlasse2). Generic type parameters of methods are embraced by square brackets (operation).

特征

Scala traits in UML

Traits are displayed like abstract classes and tagged with the stereotype trait. Abstract attributes and methods are displayed in italics (attribute2, operation2). For abstract attributes the dependency arrow can be tagged with the stereotype requires (Trait3, attribute3). On the other hand, the stereotype self is used for self referencing types (Trait4). If a trait inherits another trait, the inheritance is displayed with an inheritance arrow (Trait2). This arrow type is used too, if a class extends a trait (Klasse). To emphasis the “mix in” of traits, the inheritance arrow can be tagged with the stereotype mixin (Klasse).

单例对象

Scala singleton in UML

Singleton objects are displayed like classes and tagged with the stereotype singleton. It is possible, that there exist two class elements with the same name. In fact it is a singleton object with the belonging companion class. In this case the dependency arrow is tagged with the stereotype hasA.

关于scala - 任何适用于 Scala 的 UML 工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7815983/

相关文章:

uml - 如何在 uml 类图中表示多对多关系

generics - 在 UML 中表示泛型类继承

php - 创建并返回另一个类但不包含它的类的 UML 表示是什么?

scala - 如何将 SerialVersionUID 添加到 Scala 中的 Class[_] 实例?

scala - 如何使用 Spray 创建带有表单字段内容的 POST 请求?

scala - 如何使用新的Scala 2.8.0嵌套注释

uml - UML的常见用法

scala - 为什么使用非空构造函数扩展抽象类的 Trait 会编译?

java - 如何让 NumberFormat 使用货币但带有小数美分/便士?

java - A类与B类有聚合组合关系时,如何画UML图?