java 理解类图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1844661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
understanding class diagram
提问by cometta
Can anyone explain what the connectors mean?
谁能解释一下连接器是什么意思?

(source: stsmedia.net)

(来源:stsmedia.net)
What freeware can generate a diagram like this?
什么免费软件可以生成这样的图表?
回答by CesarGon
The dashed (dotted) lineis a dependency. It means that a class (source of the arrow) depends on another class (destination of the arrow). This is a very abstract kind of relationship, and is often annotated with further information in the form of stereotypes.
的虚线(点)线是一个依赖。这意味着一个类(箭头的来源)依赖于另一个类(箭头的目的地)。这是一种非常抽象的关系,通常以刻板印象的形式用进一步的信息进行注释。
The diamondor rhombus means a whole/part relationship. In your example, a Transaction is made ofAccounts. In UML, a white diamond is a weaker flavour of whole/part (aggregation), whereas a black diamond is a stronger variety, often called a composition. The semantics of these are poorly defined and have been shown to be flawed, though.
该金刚石或菱形指整体/部分的关系。在您的示例中,交易由帐户组成。在 UML 中,白色钻石是整体/部分(聚合)的较弱风味,而黑色钻石是更强的品种,通常称为组合。但是,它们的语义定义不明确,并且已被证明是有缺陷的。
Trianglesmean generalisation relationships. They mean that a collection of classes (sources of the triangle-pointed arrows) are specialisations of more generalised classes (destination of the triangle-pointed arrow). In your example, a Loan is a type ofProduct.
三角形表示泛化关系。它们意味着类的集合(三角形箭头的来源)是更广义类(三角形箭头的目的地)的特化。在您的示例中,贷款是一种产品。
There are many tools that can draw structural or class diagrams. About free ones, have a look at Wikipedia here.
有很多工具可以绘制结构图或类图。关于免费的,在这里查看维基百科。
回答by Brett Allen
UML has a standard, however not all people adhere to it. At wikipedia look up Class_diagram
UML 有一个标准,但并不是所有人都遵守它。在维基百科上查找 Class_diagram
Visio is the Microsoft Office software to create them, and a quick google search for Eclipse (Java) brings this http://www.mvmsoft.de/content/plugins/slime/index.htm
Visio 是用于创建它们的 Microsoft Office 软件,在谷歌上快速搜索 Eclipse (Java) 会带来这个http://www.mvmsoft.de/content/plugins/slime/index.htm
回答by sateesh
Adding to the already provided answers, applying the definitions to the provided class diagram:
添加到已经提供的答案,将定义应用于提供的类图:
An instance of Person would contain an instance of Account and since this is an
aggregation relation (represented by white diamond) it implies that an instance of
Account can exist independently of an instance of Person. Since the multiplicity details
are not provided it cannot be said how many instances of an Account a Person instance
can contain.
Person 的实例将包含 Account 的实例,并且由于这是一个
聚合关系(由白色菱形表示),这意味着
Account的实例可以独立于 Person 的实例而存在。由于
没有提供多重细节,因此不能说一个 Person 实例
可以包含多少个 Account 实例。
Similar explanation holds good for the relation between Transaction and Loan,
Person and Loan.
类似的解释适用于交易与贷款、
人与贷款之间的关系。
As answered Triangles define generalization relations and this implies inheritance.
For the provided class diagram this implies that classes Loan, ManagedFund, and Cash
are specializations of the class Product. An instance of Loan would contain attributes
that are defined in it (interest, lenders) and also would contain the
attributes name,description and managementFee that are defined in the parent class
Product.
正如所回答的三角形定义了泛化关系,这意味着继承。
对于提供的类图,这意味着类 Loan、ManagedFund 和 Cash
是 Product 类的特化。Loan 的实例将包含
在其中定义的属性(利息、贷方),还将包含
在父类
Product中定义的属性名称、描述和管理费。
回答by Malith Ileperuma
Class Diagrams
类图
Class diagram is a static diagram that represents the static view of an application
类图是表示应用程序静态视图的静态图
There are class relationships
有阶级关系
- Association - (Determination of association is somewhat related to creation of ER diagram)
- Aggression - (A particular class might consist of no of components that represent classes by itself)
- Composition - (Stronger form of aggression contained objects cannot be exist without the container object)
- Generalization - (Represent the idea of inheritance)
- 关联-(关联的确定与ER图的创建有些相关)
- 攻击性 -(一个特定的类可能不包含代表类本身的组件)
- 组合 - (没有容器对象就不能存在更强的侵略形式)
- 泛化——(代表继承的思想)
回答by Vincent Ramdhanie
The dashed line with the open arrow head means a dependency. The Account class depends on a Person Class.
Do you mean the diagram? Or generating code? Netbeans has a UML module that assist you in drawing class diagrams and can generate Java code from the class diagrams. Maybe that might help.
带有空心箭头的虚线表示依赖关系。Account 类依赖于 Person 类。
你是说图吗?还是生成代码?Netbeans 有一个 UML 模块,可帮助您绘制类图并可以从类图中生成 Java 代码。也许那可能会有所帮助。

