Relationships
关联
When you build abstractions, you’ll discover that very few of your classes stand alone. Instead, most of them collaborate with others in a number of ways. Therefore, when you model a system, not only must you identify the things that form the vocabulary of your system, you must also model how these things stand in relation to one another.
在你构建抽象事物的时候,将会发现你的类很少独立存在.取而代之的是它们中的大多数有很多方式与其它的类交互.因此,当你为某个系统建模时,不仅要从你的系统词汇表中识别事物,还要为这些事物之间的关联建模.
In object-oriented modeling, there are three kinds of relationships that are especially important:
dependencies,which represent using relationships among classes (including refinement, trace, and bind relationships ); generalizations, which link generalized classes to their specializations; and associations, which represent structural relationships among objects. Each of these relationships provides a different way of combining your abstractions.
在面向对象建模里,有三类关联特别重要:依赖,它代表的是类之间的使用关系(包括完善,跟踪和绑定关系);通用,将广义类专门化;聚合,代表对象之间的结构关系.这些关联为抽象事物提供了不同的连接方式.
Building webs of relationships is not unlike creating a balanced distribution of responsibilities among your classes. Over-engineer, and you’ll end
up with a tangled mess of relationships that make your model incomprehensible, under-engineer, and you’ll have missed a lot of the richness of your system embodied in the way things collaborate.
给关联网建模不同于在类之间创建平衡的职责分配.多余的设计使得关系犹如一团乱麻般,使你的模型难于理解;设计不足你又会错过很多富于表现系统交互的方式.