UML基本架构建模--获取关联



If you are building a house, things like walls, doors, windows, cabinets, and lights will form part of your vocabulary. None of these things stands alone, however. Walls connect to other walls. Doors and windows are placed in walls to form openings for people and for light. Cabinets and lights are physically attached to walls and ceiling. You group walls, doors, windows, cabinets, and lights together to form higher-level things, such as rooms.

如果你正在建房子,象墙,门,窗,柜和灯这类事物将形成你词汇表中的一部分.然而这类事物都不能独立存在.墙需要与其它墙相连.门和窗被固定在墙上,对人和光线形成开口.柜和灯完全地嵌在墙和天花板里.你将墙,门,窗,柜和灯组合在一起形成更高层的事物,比如房间.

 

Not only will you find structural relationships among these things, you’ll find other kinds of relationships as well. For example, your house certainly has windows, but there are probably many kinds of windows. You might have large bay windows that don’t open, as well as small kitchen windows that do. Some of your windows might open up and down; others, like patio windows, will slide left and right. Some windows have a single pane of glass; others have double. No matter their differences, there is some essential window-ness about each of them: Each is an opening in a wall, and each is designed to let in light, air, and sometimes, people.

你不仅会在这些事物之间找到结构关系,还能找到其它类别的关系.举个例子,你的房子肯定有窗户,但可能有很多不同的窗户,可能有不需要打开的大吊窗,也会有小厨房那样的窗户;窗户中有些是上下打开,其它如庭院的窗户,则是左右开窗;窗户中有些是单层玻璃,另一些是双层玻璃.无论它们之间有什么差异,它们中的每个都有基本的窗口属性:都是嵌在墙里的,都被设计为让光,空气,有时是人进入.

 

In the UML, the ways that things can connect to one another, either logically or physically, are modeled as relationships. In object-oriented modeling, there are three kinds of relationships that are most important: dependencies, generalizations, and associations.

在UML中,事物被连接到另一个事物的方法,不管是逻辑上还是物理上,都被作为关联建模.在面向对象建模中,有三种最重要的关联:依赖,泛化和联合.

 

1.Dependencies are using relationships. For example, pipes depend on the water heater to heat the water they carry.

依赖是使用的关联.举个例子,管道依靠热水器把它们装运的水加热.

 

2.Associations are structural relationships among instances. For example, rooms consist of walls and other things; walls themselves may have embedded doors and windows; pipes may pass through walls.

联合是实例之间的结构关联.比如,房间由墙和其它事物组成;墙本身可能有嵌入的门和窗;管道可能穿墙而过.

 

3.Generalizations connect generalized classes to more-specialized ones in what is known as subclass/superclass or child/parent relationships. For example, a picture window is a kind of window with very large, fixed panes; a patio window is a kind of window with panes that open side to side.

泛化建立广义类和更专业类之间的联系,被称为子类/超类或是子/父的关联.比如,以绘画装饰的窗户很大且玻璃窗固定;庭院的窗户的玻璃是能从一边向另一边打开的.

 

These three kinds of relationships cover most of the important ways in which things collaborate with one another. Not surprisingly, they also map well to the ways that are provided by most object-oriented programming languages to connect objects.

这三类关系涵盖了事物互相协作的大部分的重要的方面.毫不奇怪的是,它们也能很好的映射到大多数面向对象程序语言提供的连接对象的方法.

 

The UML provides a graphical representation for each of these kinds of relationships, as Figure 5-1 shows. This notation permits you to visualize relationships apart from any specific programming language, and in a way that lets you emphasize the most important parts of a relationship: its name, the things it connects, and its properties.

UML为这些关联的每一个提供了一个图形化的表达方式,如图5-1所示,这个标识允许你脱离任何特定的编程语言将关联可视化,用这种方式能让你理解关联的最重要部分:它的名字,它连接的事物和它的属性.

图片

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值