📄 200603071659325.html
字号:
<html>
<head><title>类图</title></head>
<center><h1>类图</h1></center>
<div><P align=right><FONT face=Verdana><FONT color=#f70938><FONT face=黑体><a href="200604112229525.html" tppabs="http://www.itisedu.com/phrase/200604112229525.html" target="_new">中科永联</a>高级技术培训中心(</FONT><FONT face=黑体>www.itisedu.com</FONT><FONT face=黑体>)<IMG src="2006327211744459.jpg" tppabs="http://www.itisedu.com/manage/Upload/image/2006327211744459.jpg" border=0></FONT></FONT></FONT></P>
<P><FONT face=Verdana> <a href="200603071659325.html" tppabs="http://www.itisedu.com/phrase/200603071659325.html" target="_new">类图</a>(<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604241343565.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200604241343565.html'" tppabs="http://www.itisedu.com/phrase/200604241343565.html" target="_new">Class diagram</a>)是显示了模型的静态结构,特别是模型中存在的<a href="200603090857555.html" tppabs="http://www.itisedu.com/phrase/200603090857555.html" target="_new">类</a>、类的内部结构以及它们与其他类的关系等。类图不显示暂时性信息。</FONT></P>
<P><FONT face=Verdana> 类图(<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604231359565.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200604231359565.html'" tppabs="http://www.itisedu.com/phrase/200604231359565.html" target="_new">Class</a> diagram)由许多(静态)说明性的模型元素(例如类、包和它们之间的关系,这些元素和它们的内容互相连接)组成。类图可以组织在(并且属于)包中,仅显示特定包中的相关内容。</FONT></P>
<P><FONT face=Verdana> 类图(Class diagram)是最常用的<a href="200602271429302.html" tppabs="http://www.itisedu.com/phrase/200602271429302.html" target="_new">UML</a>图,显示出类、接口以及它们之间的静态结构和关系;它用于描述系统的结构化设计。</FONT></P>
<P><FONT face=Verdana> 类图(Class diagram)最基本的元素是类或者接口。</FONT></P>
<P><FONT face=Verdana><STRONG>类图通常包含如下的内容</STRONG></FONT></P>
<P><FONT face=Verdana> 类<BR> 接口<BR> 协作<BR> 关系</FONT></P>
<P><FONT face=Verdana> 同其他的图一样,类图也可以包含注解和限制。</FONT></P>
<P><FONT face=Verdana> 类图中也可以包含包和<a href="200604161433025.html" tppabs="http://www.itisedu.com/phrase/200604161433025.html" target="_new">子系统</a>,这两者用来将元素分组。有时后你也可以将类的实例放到类图中。</FONT></P>
<P><FONT face=Verdana> 注:<a href="javascript:if(confirm('http://www.itisedu.com/phrase/200604161810285.html \n\nThis file was not retrieved by Teleport Pro, because it was unavailable, or its retrieval was aborted, or the project was stopped too soon. \n\nDo you want to open it from the server?'))window.location='http://www.itisedu.com/phrase/200604161810285.html'" tppabs="http://www.itisedu.com/phrase/200604161810285.html" target="_new">组件图</a>和分布图和类图类似,虽然他们不包含类而是分别包含<a href="200603302222545.html" tppabs="http://www.itisedu.com/phrase/200603302222545.html" target="_new">组件</a>和节点。</FONT></P><FONT face=Verdana>
<P><BR> 你通常通过下面三种方式使用类图:</P>
<P> 1,为系统词汇建模型<BR> 为系统的词汇建模实际上是从词汇表中发现类,发现它的责任。</P>
<P> 2,模型化简单的协作<BR> 协作是指一些类、接口和其他的元素一起工作提供一些合作的行为,这些行为不是简单地将元素加能得到的。例如:当你为一个分布式的系统中的事务处理过程建模型时,你不可能只通过一个类来明白事务是怎样进行的,事实上这个过程的执行涉及到一系列的类的协同工作。使用类图来可视化这些类和他们的关系。</P>
<P> 3,模型化一个逻辑<a href="200602271218062.html" tppabs="http://www.itisedu.com/phrase/200602271218062.html" target="_new">数据库</a><a href="200603061709535.html" tppabs="http://www.itisedu.com/phrase/200603061709535.html" target="_new">模式</a><BR> 想象模式是概念上设计数据库的蓝图。在很多领域,你将想保存持久性数据到关系数据库活<a href="200603101726185.html" tppabs="http://www.itisedu.com/phrase/200603101726185.html" target="_new">面向对象</a>的数据库。你可以用类图为这些数据库模式建立模型。</P>
<P><BR><STRONG>1. 类(Class)</STRONG> </P>
<P> 一般包含3个组成部分。第一个是类名;第二个是属性(attributes);第三个是该类提供的方法( 类的性质可以放在第四部分;如果类中含有内部类,则会出现第五个组成部分)。类名部分是不能省略的,其他组成部分可以省略。</P>
<P> 类名书写规范:正体字说明类是可被实例化的,斜体字说明类为抽象类。</P>
<P> 属性和方法书写规范:修饰符 [描述信息] 属性、方法名称 [参数] [:返回<a href="200603051002565.html" tppabs="http://www.itisedu.com/phrase/200603051002565.html" target="_new">类型</a>|类型]</P>
<P> 属性和方法之前可附加的可见性修饰符:</P>
<P> 加号(+)表示public;减号(-)表示private;#号表示protected;省略这些修饰符表示具有package(包)级别的可见性。</P>
<P> 如果属性或方法具有下划线,则说明它是静态的。</P>
<P> 描述信息使用 << 开头和使用 >> 结尾。</P>
<P> 类的性质是由一个属性、一个赋值方法和一个取值方法组成。书写方式和方法类似。</P>
<P><STRONG>2. 包(Package)</STRONG> </P>
<P> 包是一种常规用途的组合机制。UML中的一个包直接对应于Java中的一个包。在Java中,一个包可能含有其他包、类或者同时含有这两者。进行建模时,通常使用逻辑性的包,用于对模型进行组织;使用物理性的包,用于转换成系统中的Java包。每个包的名称对这个包进行了惟一性的标识。</P>
<P><BR><STRONG>3. 接口(Interface)</STRONG></P>
<P> 接口是一系列操作的集合,它指定了一个类所提供的服务。它直接对应于Java中的一个接口类型。接口的表示有大概两种方式。具体画法见下例:</P>
<P><BR><STRONG>4. 关系</STRONG></P>
<P> 常见的关系有:一般化关系(Generalization),关联关系(Association),聚合关系(Aggregation),合成关系(Composition),依赖关系(Dependency)。</P>
<P> 其中,聚合关系(Aggregation),合成关系(Composition)属于关联关系(Association)。</P>
<P> 一般关系表现为继承或实现关系(is a),关联关系表现为变量(has a ),依赖关系表现为函数中的参数(use a)。</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -