Ruby Programming Ruby (3rd) 的一段翻译,请指教

touch · 2012年07月23日 · 最后由 serco 回复于 2012年09月11日 · 3280 次阅读

Chapter 5 的第二段

We’ve already seen how classes help. All the methods in a class are automatically accessible to instances of that class. But there are other, more general types of sharing that we want to do. Maybe we’re dealing with an application that ships goods. Many forms of shipping are available, but all forms share some basic functionality (weight calculation, perhaps). We don’t want to duplicate the code that implements this functionality across the implementation of each shipping type. Or maybe we have a more generic capability that we want to inject into a number of different classes. For example, an online store may need the ability to calculate sales tax for carts, orders, quotes, and so on. Again, we don’t want to duplicate the sales tax code in each of these places.
我们已经知晓了类的功效。一个类的所有方法都可在其创建实例中灵活地调用。除此之外,我们更期望有更多的常用类型能够共享使用。假设我们要处理一个关于货轮运输的程序。有很多地运送形式可以选择,但某些基本方法对于所有的形式都是可共用的,比如重量计算。针对每一个运送类型,我们不希望照搬重复的代码,用实现每个对应类型的接口的方式完成这个功能。或者说,也许有这样一个更通用的方法,可以按我们的意愿被注入到不同的类中。例如,在线商店就需要为购物车、订单和价格等计算消费税。同样地,我们不希望在每个需要计税的地方都要复制这些代码。

第一次翻译技术文章,有很多不准确的地方,请各路高人指教,如能附上您的专业版,不胜感激!

本论坛第一篇帖子,竟然石沉大海!伤心欲绝~

#1 楼 @touch 这本书在哪里可以下载?

楼主是要翻译本书了?啥时候出版?

#2 楼 @chairy11 搜索关键字 + pdf 就有,当然,官网有付费正版

#3 楼 @skandhas 啥时候出版遥遥无期啊,很多和 2 版一样,我想试着翻译重写的章节

#4 楼 @touch 已经下载了,谢谢

#1 楼 @touch 我只能看个略懂,翻译真的很难:-)

#7 楼 @hooopo 同感,而且我觉得有些地方翻译不够准确,所以拿到这里请大家帮忙修正的

不知道什么时候能有第三版的中文版出版呢?

But there are other, more general types of sharing that we want to do. 这句是不是翻译成:除此之外,我们还需要更通用的共享(代码)的方式。

其实我觉得技术翻译需要尽量避开使用“方法”、“类型”等专有名词来指代其他的普通语义,不然很容易造成误解。比方这里的 capability => 方法。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号