如何在 UML 类图中对 Eclipse 扩展点进行建模?
对于我要做的一个软件设计项目,我选择了 Eclipse Platform 作为框架。这意味着我有很多扩展点需要实现。
但是,我在 UML 类图中指定这些扩展点时遇到了困难。那么,如何对类属于类图中的扩展点这一事实进行建模呢?
或者类图是执行此操作的错误位置吗?如果是这样,指定我实现的扩展点的最佳位置在哪里?
作为参考,我正在使用 Papyrus 进行 UML 建模。我已经有了应用程序的工作原型,因此只需创建图表即可。
干杯
for a software design project I have to do, I chose the Eclipse Platform as a framework. Meaning I have lots of extension points to implement.
However, I have trouble specifying these extension points in my UML class diagram. So how do I model the fact that a class belongs to an extension point in my class diagram?
Or is the class diagram the wrong place to do this anyway? If so, where is the best place to specify the extension points I implement?
For reference, I am doing the UML modeling with Papyrus. I already have a working prototype of the application, so it is just about creating the diagram.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
说到 Eclipse 插件,我宁愿选择组件图而不是类图。然后,您可以将扩展点建模为端口,将它们的契约建模为接口(那些棒棒糖)。
如果您宁愿使用类图将扩展点指定为具有特殊构造型(或关键字)的接口,也可以。
关于实现扩展点的类,您可以使用组件的依赖项或(在第二个解决方案中)接口实现。
Speaking of Eclipse plugins I would rather choose a component diagram than a class diagram. You can then model extension points as ports and their contract as interfaces (those lollipops).
If you rather have class diagrams specifying extension points as interfaces with a special stereotype (or keyword) would be fine as well.
Regarding the class implementing an extension point you can either use a dependency on the component or (in the second solution) an interface realization.
Eclipse 扩展点就像一个接口:它声明一组必须实现的属性。
例如,
org.eclipse.ui.editors
扩展点声明要实现此扩展点,您必须提供:在 UML 中没有确切的方式来表达这一点,因为扩展点既不是接口也不是对象,但您可以通过向模型添加构造型来对其进行建模,例如
<>
(您可以阅读有关构造型的更多信息 此处),并在图表中创建一个类(例如org.eclipse .ui.editors
),它具有所有这些属性及其所需的类型(在此示例中,所有属性都是字符串,除了class
类型为org.eclipse.ui .IEditorPart
)。之后,您可以创建另一个构造型,例如
<>
和一个具有此构造型的新类。该类与<>
类的实现链接连接,然后将所有属性的值设置为您正在实现的值。请注意,这不是“纯粹的”UML,因为您正在定义一个带有添加语义的新域,但我认为这将是一种很好且易于理解的方式来对您想要的内容进行建模。
An eclipse extension point is like an interface: it declares a set of properties that must be implemented.
For example, the
org.eclipse.ui.editors
extension point declares that to implement this extension point you have to provide:There is no EXACT way to say this in UML since an extension point is neither an interface nor an object, but you could model it by adding a stereotype to your model, say
<<extension_point>>
(you can read more about stereotypes here), and create a class in your diagram (for exampleorg.eclipse.ui.editors
) that has all of these attributes, with their required types (in this example all attributes are strings, exceptclass
which is of typeorg.eclipse.ui.IEditorPart
).After this you can create another stereotype, say
<<extension_point_implementation>>
and a new class that has this stereotype. This class you connect with a realization link from the<<extension_point>>
class, and then you set the values of all of the attributes to what you are implementing.Note that this is not "pure" UML since you are defining a new domain with added semantics, but I think that this would be a good and easy to understand way to model what you want.
从某种意义上说,扩展之于扩展点就像实例之于类一样;扩展点定义了扩展可能的属性,每个扩展都包含符合扩展点的具体属性。
In a sense extensions are to extension points what instances are to classes; extension points define the possible attributes of the extensions, and each extension contains the concrete attributes conforming to the extension point.
只需反转java代码并添加注释即可。它会完成这项工作。
Just reverse the java code and add a note. It would do the job.