如何在 UML 类图中使用众所周知的类和接口 [英] How to go with well-known classes and interfaces in an UML class diagram

查看:57
本文介绍了如何在 UML 类图中使用众所周知的类和接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于我有两个 Java 类 FooBar,并且 Bar 有一个 getFoos() 方法返回一个 List.

Given I have two Java classes Foo and Bar, and Bar has a getFoos() method that returns a List<Foo>.

在 Java 中,所有类都继承父类 Object.List 是一个接口,它扩展了接口 Collection,后者又扩展了 Iterable.所有这些都由 Java 内核提供,不需要编程.但是,它们具有可以使用或覆盖的方法.可能需要了解接口层次结构,例如采用 Iterable 的方法将接受 List.

In Java, all classes extend the parent class Object. List is an interface that extends the interface Collection, which in turn extends Iterable. All of these are provided by the Java core and do not require programming. However, they have methods that can be used or overridden. Interface hierarchy may be necessary to be known, for example a method that takes an Iterable<Foo> will accept a List<Foo>.

当在 UML 中从这些绘制类图时,我如何处理众所周知的类(Object)和接口(List,及其超接口CollectionIterable)?我是否也必须将它们绘制到图表中?我可以完全跳过它们吗?这些有没有特殊的符号(云对我来说感觉很棒)?那些应该被限定的不常见的类(即如果它是一个 java.awt.List 而不是 java.util.List)呢?>

When drawing a class diagram from these in UML, how do I do with the well-known classes (Object) and interfaces (List, and its super interfaces Collection and Iterable)? Do I have to draw them into the diagram as well? Can I skip them completely? Is there a special symbol for these (a cloud would feel great to me)? What about not-that-common classes that should be qualified (i.e. if it would be an java.awt.List and not a java.util.List)?

推荐答案

您选择如何处理知名类将取决于您计划如何使用 UML 类图.

Your choice for how to deal with well-known classes will depend on how you plan on using your UML class diagram.

如果创建 UML 图的主要目的是向团队传达设计细节,我会选择包括众所周知的类(不仅来自 JDK,还包括那些很好的类)- 在您的上下文中已知).原因是你希望你的信息有重点.添加这些众所周知的类会很快使您的图表变得混乱,而同时不会向您的消息添加任何内容.出于同样的原因,我通常会排除 getter/setter 和任何对理解设计不重要的信息.对于不太知名的课程,我将包括它们,因为它们传达的信息对于团队来说是不容易获得的.

If the main purpose for creating a UML diagram is to communicate design details to a team, I would opt for not including well-know classes (not just from the JDK but also classes that are well-known in your context). The reason being that you want your message to be focused. Adding these well-known classes can quickly clutter your diagram while adding nothing to your message. For the same reason I typically exclude getters/setters and any information that is not essential to understanding the design. For classes that are not well-known I will include them because they communicate information that is not easily accessible to the team.

如果您的类图将在 MDA 中使用,即它将用于生成系统实现,那么您必须包含众所周知的类.

If your class diagram is going to be used in MDA, i.e. it will be used to generate a system implementation, then you have to include well-known classes.

这篇关于如何在 UML 类图中使用众所周知的类和接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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