分享
 
 
 

UML翻译及学习笔记1--Class Diagrams(类图)

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Class Diagrams(类图)

Class diagrams identify the class structure of a system, including the properties and methods of each class. Also depicted are the various relationships that can exist between classes, such as an inheritance relationship. The Class diagram is one of the most widely used diagrams from the UML specification. Part of the popularity of Class diagrams stems from the fact that many CASE tools, such as Rational XDE, will auto-generate code in a variety of languages, including Java, C++, and C#, from these models. These tools can synchronize models and code, reducing your workload, and can also generate Class diagrams from object-oriented code, for those "code-then-design" maintenance projects.

类图能描述一个系统的类结构,包括每个类属性和方法(成员函数).当然,他也描述了各个类之间可能存在的各种关系,比如继承关系.类图是UML规格中使用最多的一种图.UML类图之所以能如此广泛使用是源于很多CASE(计算机辅助软件设计)工具,比如Rational XDE 能根据类图自动身成各种代码,包括Java, C++, 以及C#.这些工具能在模型和代码之间实现同步(synchronize),减轻你的工作压力,还能为那些”code-then-design”维护的工程,从面向对象的代码生成类图.

Notation(标记)

The elements on a Class diagram are classes and the relationships between them

类图中的一些元素是类以及他们之间的一些关系.

Class

Classes are the building blocks in object-oriented programming. A Class is depicted using a rectangle divided into three sections. The top section is the name of the Class. The middle section defines the properties of the Class. The bottom section lists the methods of the class.

类是OOP中的基本块.一个类由一个分为三部分的矩形表示.顶层的部分表示类名.中间部分是类的一些属性(成员变量).底层的是类的方法列表(成员函数).

Association

联合

An Association is a generic relationship between two classes, and is modeled by a line connecting the two classes. This line can be qualified with the type of relationship, and can also feature multiplicity rules (eg. one-to-one, one-to-many, many-to-many) for the relationship.

联合是两个类之间的最泛指(generic)的关系,由一个联系两个类的直线表示.这条线可以由联系的类型所qualified,也能表示一些multiplicity规则(比如 1对1, 1对多,多对多)

Composition

组成

If a class cannot exist by itself, and instead must be a member of another class, then that class has a Composition relationship with the containing class. A Composition relationship is indicated by a line with a filled diamond.

如果一个类不能自己存在, 一定要作为另外一个类的成员而存在,那么这个类和那个包含他的类之间就由一个组成关系.(比如Ferrari的generator一定要装在他的汽车里嘛).一个组成关系由一个带实心菱形的直线表示.

Dependency

依赖

When a class uses another class, perhaps as a member variable or a parameter, and so "depends" on that class, a Dependency relationship is formed. A Dependency relationship is indicated by a dotted arrow.

如果一个类要使用另外一个类,可能是一个成员变量或是一个参数,于是这个类就依赖于那个类,一个依赖关系就形成了.一个依赖关系由一个带箭头的虚线表示.

Aggregation

聚合,聚集

Aggregations indicate a whole-part relationship, and are known as "has-a" relationships. An Aggregation relationship is indicated by a line with a hollow diamond.

聚集关系表示一个总体和部分的关系,可以由”has-a”连接的两个类就有聚集关系.聚集关系由一个带空心菱形的直线表示..

Generalization

泛化

A Generalization relationship is the equivalent of an inheritance relationship in object-oriented terms (an "is-a" relationship). A Generalization relationship is indicated by an arrow with a hollow arrowhead pointing to the base, or "parent", class.

泛化关系和OO里的继承关系是等价的,可以由”is-a”连接的两个类之间存在此类关系.一个泛化的关系由一个带空心三角的箭头表示,箭头指的是父类.

Consider the example of a veterinary system. Animals served, such as dogs and birds, are tracked along with their owners. The following diagram models a potential solution. Since dogs and birds are "a kind of" animal, we use a Generalization relationship.

现在考虑一下一个兽医站的例子. 小动物受到照顾, 比如狗狗小鸟, 他们都和他们的主人一道来的.以下的这个图模型是一个可行的方案.

应为狗狗和鸟都是”一种”动物(不过狗会咬人~~~````还有狂犬病

),我们用了一个泛化的关系,也就是一个继承的关系.

如有翻译不当之处,望各位高手不啬指出,本来先谢过大家了

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有