SCSF. Chapter 1. C. Smart Client Software Factory (SCSF)
Feedback 反馈 from the original release of CAB provided an object lesson to Microsoft. Developers liked the idea of a prefabricated toolkit for writing rich client applications. However, these developers reported that they found CAB difficult to use for two main reasons.
通过CAB的原始版本反馈,为喜欢预构建工具的微软开发者提供了一节目标课程来编写胖客户端程序。尽管如此,这些开发者报告有两个原因使得CAB很难开发。
First, few tools existed for helping them develop CAB applications. There were, for example, no wizards to generate the shell of a CAB application. Developers had to generate a standard Windows Forms project and modify the application files to make it use the CAB libraries. They had to cut and paste lots of code, do more repetitive 重复的 (grunt work) 枯燥的工作 than they had to do with other types of applications—more than they felt that they should have had to. If you remember writing an original Windows Software Developer Kit (SDK) program (RegisterClass, CreateWindow, ShowWindow, GetMessage, TranslateMessage, DispatchMessage, Window response function, WM_PAINT, etc.), beginning every project with an extensive 大量的 cut-and-paste session from some other Windows project, you'll understand the feeling. The architectural goodness of CAB was apparent 显然的 to developers, but many felt that the price of grunt work necessary to use it was higher than it should have been, higher than they were willing to pay. For another analogy, think of the Microsoft Foundation Classes (MFC): nice prefabricated toolkit. Now imagine it without Class Wizard, its main automation tool. You could use it and maybe still make a profit 有益于 over using the SDK, but too much of the time savings from prefabrication would get lost in the cutting and pasting. That's what CAB was like on its first release.
第一,只有很少的可用工具来帮助CAB程序开发。那里有,例如,没有向导程序去生成一个Shell of a CAB程序。开发者需要生成一个标准winform工程,然后修改文件去使用CAB库。他们需要剪切和粘贴许多代码,做更多重复的枯燥的工作,相比他们需要完成的其他类型的工作—比他们认为需要做的工作更多。如果你记得编写原始windows SDK程序,以大量的通过其他windows工程的剪切和粘贴会话为开始,你会理解这种感受。CAB的架构精华对开发者而言是不言而喻的,但是花费在枯燥工作上的代价比必要的要多,比大家愿意花费的更多。做另外一个类比,想想MFC:美好的预构建工具。现在想想如果它没有类向导,以及它的自动工具。你可以使用它并且更好的使用SDK,避免陷入剪切和粘贴,从而节约更多的时间。这就是CAB在第一个发行版的样子。
Second, since CAB was very new, a number of architectural issues hadn't been worked through completely by the time of its release. Here's one small but omnipresent 无所不在的 example: How should the various 各种各样的 work items share and communicate with the status bar's main message string? Expose it directly as a class? Place it on the root work item? Do something else? Here's another: Should you derive 得自 a new class for each WorkItem or use the same WorkItem class for each one and express 表现 differences in business logic through some sort of object contained within the WorkItem? Developers still had architectural work to do on the infrastructure of their rich client programs. They hadn't yet been completely freed to concentrate 集中 only on their business logic.
第二,因为CAB很新,当它发布的时候一些架构上的问题还没有完全完成。这里有一个小的但却无所不在的例子:如何使得各种各样的work items共享以及与状态栏通信?像一个类一样直接显示?把它放在root work item中?还是做些其他事情?这里还有另外一个问题:你是通过每个workitem去获得一个新的类,还是通过同一个类去生成,同时通过workitem包含的类来表现不同的业务逻辑。开发者仍然需要做架构方面的工作。他们并没有完全被释放在集中于业务逻辑。
To solve these problems, Microsoft release the Smart Client Software Factory, or SCSF (originally called SC-BAT). This is a set of code, documentation, and tools that illustrate 图解/举例说明 and ease the task of following the design patterns that experience has shown are optimal 最佳的 for most CAB applications. The first version shipped in July 2006, and the second version in May of 2007, just before this book went to press. SCSF contains three main enhancements to baseline CAB.
为了解决这些问题,微软发布了SCSF。这是一个代码,文档和工具集,举例说明并且遵循设计模式来达到最佳的CAB程序。第一个版本发布在2006年7月,第二版在2007年5月,就在本书出版之前,SCSF比最初版本的CAB多包含了三个主要提高。
First, SCSF contains a number of classes that provide brand-new functionality that CAB developers wanted but that weren't included in the base release. For example, the 2006 release contains the Dependent Module Loader service and the ActionCatalogService. The 2007 release contains support for Windows Presentation Framework, as well as classes for handling disconnected and intermittently connected operation. This functionality is included in the SCSF and not in the baseline CAB assemblies. If you think of these additions as CAB .1 and .2, which get added to the baseline CAB libraries to produce versions 1.1 and 1.2, you'll have the right mental model 心理模型.
第一,SCSF包含了一些类提供了全新的功能,那些CAB开发者想要的但是第一个版本没有包含的功能。例如,2006版包含Dependent Module Loader service and the ActionCatalogService。2007版本包含WPF支持,包括处理断开和间断连接处理的类。这些功能包含在SCSF中并且不包含在CAB程序集中。你可以认为这些新增是CAB .1 和 .2。
Second, SCSF contains classes that provide architectural guidance to developers. For example, the ControlledWorkItem class (see Chapter 3) is sealed, thereby indicating to the developers who use it that they should not derive new classes from it. It also provides easy access to and from a Controller object, thereby indicating to developers that business logic belongs on this controller.
第二,SCSF为开发者提供了包含架构向导的类库。例如,Controller work item类是密封的,因此对于使用这些类的开发者而言无法获得新的类。它也提供了Controller对象的简单入口,因此对开发者而言业务逻辑依赖于controller。
Third, SCSF contains a set of tools known as a Guidance Package. This Visual Studio plug-in generates code that implements the recommended design patterns. If you think of this as analogous to the MFC Class Wizard, you'll have the right mental model.
第三,SCSF包含一个向导包的工具集。这个VS插件可以生成实现被推荐的设计模式的代码。如果你能类比MFC类向导,你就找到了一个正确的方向。
Platt's Third Law of the Universe states simply: "Laziness trumps everything." According to this law, all human beings are inherently lazy and will do the absolute minimum amount of work they can get away with under any circumstances 情况. Therefore (first corollary), that which is easy to do will be done frequently, whether it should be or not, and that which is hard to do will be done infrequently, whether it should be or not. Therefore (second corollary), a good design makes the good, safe, smart things easy to do, and the bad, dangerous, stupid things hard to do. SCSF makes writing good code easier than writing bad code (mostly, usually); therefore, more good code will be written and less bad code.
Platt的宇宙第三定律:“懒惰胜过一切”。通过这条定律,人类天性懒惰并且在某些情况下他们只做最少的工作。因此(首先推论),通常先完成最简单的事情,无论是否如此,困难的工作应该极少的发生,无论是否如此。因此(第二推论),良好的设计导致使得事情变得简单,安全和美好,而糟糕、危险和愚蠢的事情很难发生。SCSF使得写好代码比差代码更简单;因此,编码中会产生更多好代码和更少的差代码。
The first generation of CAB developers, whom I taught in the first half of 2006, were drawn to CAB by its modular architecture, especially for large and complex applications. They felt that following the CAB design patterns would be good for their applications in the long run even if it took more effort today, like flossing their teeth. With the release of SCSF, these developers are happier because the flossing got easier, an unexpected advantage. But the release of SCSF also attracted 吸引 an entirely 完全的 new set of developers who view SCSF-CAB as a convenient 方便 toolkit for producing even small applications more quickly and easily than they previously could. They see an economic 经济 gain from prefabrication 预加工的, again, conceptually 概念的 similar to the way the MFC and its wizards made desktop application development easier than a raw SDK application. To take the dental analogy one step further, they perceive that this new automatic brusher-flosser machine (SCSF-CAB) is faster and easier than brushing alone the old manual way (plain Windows Forms).
第一代CAB开发者,我在2006年上半年教授的,是被CAB的模块化架构所吸引,特别是大型和复杂程序。他们觉得依照CAB设计模式会长远看来对他们的程序是更好的,即使要花费更多精力,就像是用牙线清理牙齿。随着SCSF的发布,这些开发者会更加乐意,因为用牙线更简单了,一项出人意料的优势。SCSF也吸引了一批全新的把SCSF-CAB作为方便开发工具的开发者,他们可以比以往开发的更加简单和快捷。他们可以看见从预构建中获取经济利益,同时,开发更类似于MFC向导开发,使得桌面应用程序比未加工的SDK程序更容易开发。把刚才的牙科类比更进一步,他们认识到这个新的自动化牙线机器(SCSF-CAB)比单独刷牙更加简单快捷(plain windows forms)。
Clients often ask me which version of CAB to use, baseline or SCSF? I always recommend the SCSF version. Not only is it much easier to use, but it contains the invaluable experience of the first generation of CAB developers. I will use the SCSF version of CAB throughout this book, except in the next section of this chapter.
客户经常问我应该用原版的CAB还是SCSF?我总是推荐SCSF。不只是因为它简单,而是因为它包含了第一代CAB开发者无价的宝贵经验。我将在本书中至始至终使用SCSF,特别是在本章中的下一节。
The May 2007 release of SCSF installs signed binary versions of CAB DLLs. You do not have to install the baseline release of CAB to use it. The CAB library source code is automatically installed when you install the SCSF source code. The course installs itself in your Visual Studio 2005 Projects folder.
2007年五月发布的SCSF将安装签名的二进制CAB DLLs。因此你无须再次安装CAB。当你安装SCSF源代码时,CAB库的源代码也会被自动安装。这个课程将会把它安装在VS 2005文件夹下。


浙公网安备 33010602011771号