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.
給關聯網建模不同於在類之間創建平衡的職責分配.多餘的設計使得關係猶如一團亂麻般,使你的模型難於理解;設計不足你又會錯過很多富於表現系統交互的方式.