UML基本架构建模--给关联建模时的注意事项

本文详细阐述了在UML中构建关系模型时的准则,包括使用依赖、泛化、联合等关系的方式,以及如何在绘制关系时保持一致性、避免交叉线和不必要的关系。同时提供了关于关系模型构建和绘图的实用建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



When you model relationships in the UML,

lUse dependencies only when the relationship you are modeling is not structural.

lUse generalization only when you have an is-a-kind-of relationship; multiple inheritance can often be replaced with aggregation.

lBeware of introducing cyclical generalization relationships.

lKeep your generalization relationships generally balanced; inheritance lattices should not be too deep ( more than five levels or so should be questioned ) nor too wide ( instead, look for the possibility of intermediate abstract classes ).

lUse associations primarily where there are structural relationships among objects. Do not use them to show transient relationships such as parameters or local variables of procedures.

 

当你在UML中构建关系模型时,

l当你所建的关系模型不是结构型的才能使用依赖.

l当你有一个是一个种类的关系时使用泛化;多重继承通常被聚合替换.

l当心引进循环泛化关系.

l让你的泛化关系总体上保持平衡;继承框架不能太深(超过五层左右应该仔细斟酌)也不能太宽(相反,找中间抽象类的可能性).

l使用联合主要是在对象之间存在结构关系.不要用它们来表现临时的关系,如参数或是过程的局域变量.

 

When you draw a relationships in the UML,

lUse either rectilinear or oblique lines consistently. Rectilinear lines give a visual cue that emphasizes the connections among related things all pointing to one common thing. Oblique lines are often more space-efficient in complex diagrams. Using both kinds of lines in one diagram is useful for drawing attention to different groups of relationships.

lAvoid lines that cross unless absolutely necessary.

lShow only those relationships that are necessary to understand a particular grouping of things. Superfluous relationships ( especially redundant associations ) should be avoided.

当你在UML中画关系时,

l直线或是斜线在使用上的一致性.直线线条给视觉提示,强调相关事物之间的联系都指向同一个事物.斜线通常在复杂图表中更节省空间.在一个图表中使用这两种线条,绘画过程中注意不同群组的关系是有用的,

l除非迫不得以,否则避免交叉线.

l只显示那些有助于理解一个事物的特定群组的关系.应避免多余的关系(尤其是累赘的联合).

 

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值