以下是第二章的部分勘误:
26(8)还需要考虑客户端增加Finalize方法,而忘记使用Dispose方法的这种可能性。 建议:考虑到客户端有可能忘记调用Dispose方法,我们还要添加一个Finalize方法。 原文:You also need to account for the possibility that the client will forget to use the Dispose method by adding a
Finalize method.
27(3)如果您是一位企业级的编程高手,那么您已经知道不能过分依赖客户端的行为完全合理和追求像调用Dispose方法这样的细节。其
中原因之一就是提供服务的类总是无状态的,所以要确保这样的问题不会发生。 建议:如果您是一位有经验的企业应用程序员,那么您应该知道不能依靠客户端按部就班、遵循诸如调用Dispose方法这样的步骤。这
也是提供服务的类总是无状态的其中一个原因,这样就能确保这种问题不会发生。 原文:If you're a seasoned enterprise programmer, you already know that you can't rely on clients to behave properly
and follow details such as calling a Dispose method. That's one of the reasons that service provider classes are
always stateless, thereby ensuring that these problems can't occur.
27(10)有时候或许发现服务提供者在设计上的变化,把适应它的连接字符串作为一个属性,或者在构造函数中设置连接字符串。 建议:有时候您还能看到服务提供者的另外一种设计(方案),该设计提供一个连接字符串的属性,或者在构造函数中要求连接字符串
参数。 原文:Sometimes you might see a variation of the service provider design that provides its connection string as a
property or requires the connection string in its constructor. 评论:这个“适应它”真不知从何而来。
29(2)配置文件有利于另一些存储设置的方法,因为它们从来不会被锁定,并且能够在任意时间里进行编辑。 建议:配置文件之所以优于其它存储设置的方法,在于它们不会被锁定,因而能随时编辑。 原文:Configuration files are favored over other methods of storing settings because they are never locked and can
therefore be edited at any time.
29(3)配置文件使用起来也很方便,因为它们和特定的目录相关联,而不是和计算机相关联(注册表设置也是如此)。 建议:配置文件使用起来也很方便,因为它们和特定的目录相关联,而不是(象注册表设置那样)和特定的计算机相关联。 原文:Configuration files are also convenient because they are tied to a particular directory, not a particular
computer (as a registry setting would be).
29(6)在某些例子中,取决于您的部署的情况,一个配置文件可能会给客户端非常多的机会来修改连接字符串,并且可能需要在类里面
直接编译它(跟早先所介绍的一样)或者从Web服务中检索它。 建议:在某些情况中,由于您所采取的部署方式,配置文件(这种存储设置的方法)可能很容易让客户端修改连接字符串,(这时)您
可能需要直接把它编译到类里面(跟早先所介绍的一样)或者从Web服务中获取。 原文:In some cases, depending on the deployment you use, a configuration file might give the client too much
opportunity to modify the connection string and you might need to compile it directly in the class (as shown earlier)
or retrieve it from a Web service.
33(13)Probing是一个进程,.NET通过它来搜索那些没有指定配置的私有程序集。 建议:探测(Probing)是指.NET搜索那些没有明确配置的私有程序集的过程。 原文:Probing is the process by which .NET searches for private assemblies that aren't specifically configured.
33(17)如果对引用的程序集指定过路径信息,那么它会在指定区域子目录而非应用程序路径中执行一个非自动搜索的相似的查询企图。 建议:如果对引用的程序集指定了语言文化信息,那么它会在特定语言文化的子目录而非应用程序路径中执行类似的查找。 原文:If you have specified culture information for the referenced assembly, it performs a similar lookup attempt but
automatically searches in the culture-specific subdirectory rather than the application path.
34(17)这大大违背了COM编程的原则和便利有效的原则。 建议:这与COM编程大不相同而且非常方便。 原文:This is a major departure from COM programming and a significant convenience.
34(18)采用COM编程的时候... 建议:跟COM编程一样... 原文:As with COM programming, you can introduce new versions of a method by adding a new interface to your component
so as not to disturb existing clients.
34(-10)GAC让您在各个终端安装独立的组件版本。 建议
|