SCSF. Chapter 3. B. Solution Architecture
A work item, represented by the class WorkItem, is the basic unit of software scoping in CAB. It contains well-known collections of objects such as services, workspaces, and Smart Parts, so that loosely coupled objects know where to find the resources that they need to do their work. It represents the primary mechanism whereby 凭借 the loosely coupled parts of a CAB application are stitched together. In the preceding chapter, you saw the loosely coupled way in which a WorkItem contains services, making them available to other parts of a program.
一个work item,由WorkItem 类所代表,是CAB的软件范围基本部件。它包含了容易理解的对象集合,例如services, workspaces, and Smart Parts,因此松耦合对象知道他们工作所需要的资源在哪里。它代表了CAB程序如何把松耦合部件缝在一起的主要的策略。在之前的章节中,你看到包含服务的workItem中的松耦合方式,让他们在程序中对其他部件可用。
The philosophy 哲学 and purpose of the WorkItem have evolved 进化了的 greatly since its origin. The original idea was that a WorkItem object represented a particular 特别的 use case—that is, one job of work, say a particular credit card operation. You would derive a new class from the base WorkItem and place business logic methods on it, as is seen in much of the early CAB samples and documentation. But it soon became apparent that (a) this granularity 粒度 was too fine-grained 细纹理分布的 because WorkItems were multiplying 繁殖 unnecessarily 不必要的, (b) the resources held by a single WorkItem were often of interest to many instances of the same sort of use cases, and (c) the derived WorkItem class became too complex to effectively 有效的 develop and test.
WorkItem的哲学与目标相比原始的发生了很大的进化。最原始的想法是workItem对象代表一个特别的使用场景,例如信用卡操作场景。你通过基础workItem派生一个新的类并把业务逻辑方法放在其中,就像早先的CAB例子与文档中看到的。但是它迅速变成这样(a)因为workItem繁殖的太多余了使得场景分布变密了(b)一个workItem钟存在的资源被同样类型的实例所需求(c)派生于workItem的类对开发和测试而言变得复杂。
The current SCSF philosophy uses the WorkItem only as a container of other objects. You can think of a WorkItem as a scoping container in the same way as a Win32 process or a CAB AppDomain is a scoping container. The boundaries 边界 between WorkItems are easier to traverse 穿过 than those others, but if you think of a WorkItem as a miniature 微型的 subprocess 子过程 or subapplication 子程序, you'll have the right mental model.
现在的SCSF哲学是使用workItem只作为一个对象的容器。你可以把WorkItem作为一个范围容器,就像是win32 process或者CAB AppDomain一样。WorkItem间的边界更容易穿越 ,但是如果你把workItem看做一个微型的子过程或子程序,你得到了正确的心智模型。
The business logic of a WorkItem now lives in a separate class called a controller, which the WorkItem contains. The relationship between the WorkItem class and its business logic has changed from "is-a" to "has-a." I discuss controllers in the last section of this chapter.
WorkItem的业务逻辑现在存在于分离的类中叫做controller,是workItem所包含的。workItem类和它的业务逻辑之间的关系由“是一个”变成了“有一个”。我在最后章节讨论controller.
WorkItems are arranged 安排 in a tree-like chain, as shown on the facing page. The root work item, the base of the chain, is created by the shell application as part of its start-up process, as you saw in the preceding chapter. When modules are loaded into the process, they create work items and add them as children to the root work item's chain. The code for this is shown in section D of this lesson. Sometimes a module adds more than one work item, as does Module B in the diagram.
WorkItems被组织在树型链表中,就像在表页上所展示的。Root work item,这个链表的基础,是被shell application所创建的做为启动过程的一部分,你在前一章已经看过了。当modules被加载到过程中,他们创建work item被被作为children添加到root work item的链表中。代码在Section D中被展示,有时module添加不知一个work Item。就像module B在图表中那样。
The WorkItem class contains properties that allow you to traverse 穿过 this tree. The property Parent returns the parent WorkItem, and the property RootWorkItem takes you directly to the top of the chain. The child WorkItems of a WorkItem (in the diagram, 1 and 2 are children of the root, and 3 and 4 are children of 2) are located in the collection named WorkItems.
workItem类包含了让你穿过这棵树的属性。parent属性返回parent workItem,rootWorkItem属性把你直接带到链表的最顶部。子workItem在集合中的名称是workitems。
For the lack 缺乏 of a better word, and to use a highly overloaded 超载的 one, the WorkItem to which an object belongs represents that object's context, the place in which it lives, the sea in which it swims.
无法找到一个更适合的词语,只能用一个有些过分的词语,workitem对于存在于其中的对象而言,就像大海任其遨游。
Figure 3-1. WorkItem tree.

浙公网安备 33010602011771号