UML基本架构建模--关联的通用建模技术(三)[整理]
Modeling Structural Relationships
建模结构关系
When you model with dependencies or generalization relationships, you may be modeling classes that represent different levels of importance or different levels of abstraction. Given a dependency between two classes, one class depends on another but the other class has no knowledge of the one. Given a generalization relationship between two classes, the child inherits from its parent but the parent has no specific knowledge of its children. In short, dependency and generalization relationships are asymmetric.
当你用依赖或泛化关系建模时,你可以构建的类代
表
关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf
不同
层次的重要性或是不同层次的抽象概念,给定一个在两个类
之间的依赖,一个类依赖着另一个类,而这个被依赖的类并
不知道有类依赖着它,给定一个两个类之间的泛化关系,子
类继承自父类,但父类对它的子类没有具体的了解,总之,
依赖和泛化关系是不对称的,
When you model with association relationships, you are
modeling classes that are peers of one another. Given an association between two classes, both rely on the other in some way, and you can often navigate in either direction. Whereas dependency is a using relationship and generalization is an is-a-kind-of relationship, an association specifies a structural path across which objects of the classes interact.
当你用联合关系建模时,你正在建模的类互相之间是对等
的,给定一个连接两个类的联合,两个类在某种方式上互相
依赖,你通常可以在两个方向上浏览,依赖是使用关系,泛
化是类别关系,而一个联合则是指定类的对象进行交互的结
构路径,
To model structural relationships,
, For each pair of classes, if you need to navigate from
objects of one to objects of another, specify an
association between the two. This is a data-driven view
of associations..
, For each pair of classes, if objects of one class need to
interact with objects of the other class other than as
local variables in a procedure or parameters to an
operation, specify an association between the two. This
is more of a behavior-driven view of associations.
, For each of these associations, specify a multiplicity
(especially when the multiplicity is not *, which is the
default), as well as role names (especially if they help to
explain the model).
, If one of the classes in an association is structurally or
organizationally a whole compared with the classes at
the other end that look like parts, mark this as an
aggregation by adorning the association at the end near
the whole with a diamond.
建模结构关系,
, 为每一对类
, 为每一对类
, 这些联合关系的每一个
, 如果在联合关系里类中的一个,
How do you know when objects of a given class must interact with objects of another class? The answer is that CRC cards and use case analysis help tremendously by forcing you to consider structural and behavioral scenarios. Where you find that two or more classes interact using data relationships, specify an association.
你怎么知道
Figure 5-11 shows a set of classes drawn from an information system for a school. Starting at the bottom left of this diagram, you will find the classes named Student ,
Course, and Instructor. There’s an association
between Student and Course, specifying that students
attend courses. Furthermore, every student may attend any number of courses and every course may have any number of students. Similarly, you’ll find an association
between Course and Instructor, specifying that
instructors teach courses. For every course there is at least one instructor and every instructor may teach zero or more courses, each course belongs to exactly one department.
在图5-11中显示的来自校园信息系统的一组类,
The relationships between School and the classes
Student and Department are a bit different. Here you’ll
see aggregation relationships. A school has zero or more students, each student may be a registered member of one or more schools, a school has one or more departments,
and each department belongs to exactly one school. You could leave off the aggregation adornments and use plain associations, but by specifying that School is a whole and
that Student and Department are some of its parts, you
make clear which one is organizationally superior to the other. Thus, schools are somewhat defined by the students and departments they have. Similarly, students and departments don’t really stand alone outside the school to which they belong. Rather, they get some of their identity from their school.
学校和学生类之间的关系与学校和部门之间的关系有点
不同,
.
You’ll also see that there are two associations between Department and Instructor. One of these
associations specifies that every instructor is assigned to one or more departments and that each department has one or more instructors. This is modeled as an aggregation because organizationally, departments are at a higher level in the school’s structure than are instructors. The other association specifies that for every department, there is exactly one instructor who is the department chair. The
way this model is specified, an instructor can be the chair of no more than one department, and some instructors are not chairs of any department.
你还会看到
Note: ,Your school might not have departments. You might have chairs who are not instructors, or you might even have students who are also instructors. That doesn’t mean that the
model here is wrong, it’s just different. You cannot model in isolation, and every model like this depends on how you intend to use these models.
备注,你的学校也许没有部门