Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

类(Class)与数据结构(Data Structures) #6030

Merged

Conversation

EmilyQiRabbit
Copy link
Contributor

译文翻译完成,resolve #5998

@EmilyQiRabbit EmilyQiRabbit changed the title Update classes-vs-data-structures.md 类(Class)与数据结构(Data Structures) Jun 24, 2019
@JalanJiang
Copy link
Contributor

校对认领

@fanyijihua
Copy link
Collaborator

@JalanJiang 好的呢 🍺

Copy link
Contributor

@JalanJiang JalanJiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

校对完成 @leviding @EmilyQiRabbit


> **It could be; but there’s no rule that says it must be. From the point of view of the user, an object is nothing more than a set of functions. The data that those functions operate upon must exist, but the location of that data is unknown to the user.**
> **这是有可能的,但是并没有强制规定必须这样。从用户的角度来看,对象仅仅是一组函数。这些函数操作的数据一定存在,但是这些数据的位置对用户是保密的。**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『但是这些数据的位置对用户是保密的。』=>『但是这些数据的位置对用户来说是未知的。』

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“未知”或者“保密”感觉都可以的吧。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处强调的是「数据存在但用户不可知」,用保密的话感觉是在强调「刻意不让用户得知」,此处表达「用户不知」的意思即可。这是我个人的意见。


> **Indeed. They are complements of each other. They fit together like a hand in a glove.**
> **确实是这样。它们是互补的。它们就像手和手套一样组合在一起。**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『它们就像手和手套一样组合在一起。』=>『它们就像手和手套一样契合。』


Oh, I see. Since the database schema is a compromise of all the various applications, that schema will not conform to the object model of any particular application.
哦,我懂了。既然数据库模式是左右不同对象的折中选择,那么这个模式和任何一个应用的对象模型都能不恰好匹配。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『既然数据库模式是左右不同对象的折中选择』=>『既然数据库模式是各种应用程序的折中选择』


> **Right! Objects and Data Structures are constrained by very different forces. They seldom line up very nicely. People used to call this the Object/Relational impedance mismatch.**
> **正确!对象和数据结构都被非常不同的条件约束。它们很少能够完美的契合。人们习惯称之为对象/关系阻抗不匹配。**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『它们很少能够完美的契合。』=>『它们很少能够完美地契合。』

「契合」这里为动词,需要用助动词「地」。


> **Let’s just consider two different types: `Square`s and `Circle`s. It should be clear that the `area` and `permimeter` functions of these two classes operate on different implied data structures. It should also be clear that the way those operations are called is via dynamic polymorphism.**
> **我们来考虑两个不同的形状:方形和圆形。我们都知道,这两种类的周长和面积的计算函数是操作不同的隐含的数据结构的。我们也都知道,这些操作被调用的方式是通过动态多态性。**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『这两种类的周长和面积的计算函数是操作不同的隐含的数据结构的』=>『这两种类的周长和面积的计算函数对不同的隐含数据结构进行操作』


> **Correct. All the source file dependencies point in the direction of the call, from the caller to the implementation. So if you make a tiny change to one of those implementations…**
> **正确。所有源文件依赖都指向调用的方向,从调用者到实现。所以,如果你在这些实现中做了一个错误的修改...**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


OK, I see where you are going with this. A change to any one of the implementations will cause the source file with the switch statement to be recompiled, which will cause everyone who calls that switch statement – the `area` function in our case – to be recompiled.
好的,我明白你的意思了。任何一个实现中的修改都将会导致具有切换状态的源文件被重新编译,从而导致任何使用了这个状态切换了的函数 —— 比如我们的面积计算函数 —— 被重新编译。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『任何一个实现中的修改都将会导致具有切换状态的源文件被重新编译,从而导致任何使用了这个状态切换了的函数 —— 比如我们的面积计算函数 —— 被重新编译。』=>『任何一个实现中的修改都将会导致具有 switch 语句的源文件被重新编译,从而导致任何使用了这个 switch 语句的函数 —— 比如我们的面积计算函数 —— 被重新编译。』


> **Right. The source files of the implementation point in the opposite direction of the call. They point from the implementation to the caller. At least that’s true for statically typed languages. For dynamically typed languages the caller of the `area` function depends upon nothing at all. The linkages get worked out at run time.**
> **是的。包含了实现的源文件指向调用相反的方向。是从实现指向调用者的。至少对于静态类型语言这是肯定的。而对于动态类型语言,面积函数的调用者根本不依赖与任何。只在运行时才能找到它的依赖。**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『而对于动态类型语言,面积函数的调用者根本不依赖与任何。』=>『而对于动态类型语言,面积函数的调用者完全不依赖于任何东西。』


Right. OK. So if you make a change to one of the implementations…
没错,是这样。所以如果你修改了其中一个实现...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* Data Structures expose callers to recompilation and redeployment. Classes isolate callers from recompilation and redeployment.
* 类暴露出函数而隐藏数据。数据结构暴露数据但是隐藏函数。
* 类让增加类型容易,但是增加方法很困难。数据结构让增加函数很容易,但是增加类型困难。
* 数据结构让调用者需要反复编译和部署。类将调用者从需要反复编译和部署的部分隔离开了。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『类将调用者从需要反复编译和部署的部分隔离开了。』=>『类将调用者从反复编译和部署中解脱。』

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉还是“隔离”好一些。其次,isolate from 是个短语用法,表示“使…隔离,使隔离”

@leviding leviding added the enhancement 等待译者修改 label Jun 24, 2019
@suhanyujie
Copy link
Contributor

校对认领 @leviding

@fanyijihua
Copy link
Collaborator

@suhanyujie 妥妥哒 🍻

@EmilyQiRabbit
Copy link
Contributor Author

@JalanJiang 感谢校对~棒棒哒!

Copy link
Contributor

@suhanyujie suhanyujie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

翻译的很赞,很流畅,有些地方稍微调整了一下,给了些建议。保持沟通
@leviding @EmilyQiRabbit


> **It could be; but there’s no rule that says it must be. From the point of view of the user, an object is nothing more than a set of functions. The data that those functions operate upon must exist, but the location of that data is unknown to the user.**
> **这是有可能的,但是并没有强制规定必须这样。从用户的角度来看,对象仅仅是一组函数。这些函数操作的数据一定存在,但是这些数据的位置对用户是保密的。**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“未知”或者“保密”感觉都可以的吧。


Oh, I see. Since the database schema is a compromise of all the various applications, that schema will not conform to the object model of any particular application.
哦,我懂了。既然数据库模式是左右不同对象的折中选择,那么这个模式和任何一个应用的对象模型都能不恰好匹配。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『既然数据库模式是左右不同对象的折中选择,那么这个模式和任何一个应用的对象模型都能不恰好匹配』
=>
『由于数据库模式是左右不同对象的折中选择,所以这个模式不会和某个特定的应用对象模型匹配』

  • since 有 “既然,由于”等意思,感觉此处用“由于”会更合适一些。


Then the source file with the switch statement would have to import, or use, or include, all those source files.
那么这些需要做状态切换的源文件就需要导入,或者使用,或者包含所有这些源文件。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『那么这些需要做状态切换的源文件就需要导入』
=>
『那么这些带有 switch 语句的源文件就需要导入』


OK, but this is reversed in the case of classes?
好吧,但是这些缺点在使用类的场景下可以被逆转吗?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 感觉此处 reversed 可以译为“被解决”


> **Right. The source files of the implementation point in the opposite direction of the call. They point from the implementation to the caller. At least that’s true for statically typed languages. For dynamically typed languages the caller of the `area` function depends upon nothing at all. The linkages get worked out at run time.**
> **是的。包含了实现的源文件指向调用相反的方向。是从实现指向调用者的。至少对于静态类型语言这是肯定的。而对于动态类型语言,面积函数的调用者根本不依赖与任何。只在运行时才能找到它的依赖。**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『包含了实现的源文件指向调用相反的方向。是从实现指向调用者的』
=>
『包含了实现的源文件在调用的相反方向有作用。它们是从实现指向调用者的』

  • 查了一下 point in,有“在…有作用”的意思。这样用貌似通顺一点。

* Data Structures expose callers to recompilation and redeployment. Classes isolate callers from recompilation and redeployment.
* 类暴露出函数而隐藏数据。数据结构暴露数据但是隐藏函数。
* 类让增加类型容易,但是增加方法很困难。数据结构让增加函数很容易,但是增加类型困难。
* 数据结构让调用者需要反复编译和部署。类将调用者从需要反复编译和部署的部分隔离开了。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉还是“隔离”好一些。其次,isolate from 是个短语用法,表示“使…隔离,使隔离”

@JalanJiang
Copy link
Contributor

JalanJiang commented Jun 25, 2019

校对者信息中麻烦标注我博客的地址:http://jalan.space/
感恩~ @EmilyQiRabbit

@EmilyQiRabbit
Copy link
Contributor Author

@JalanJiang @suhanyujie 感谢校对

@EmilyQiRabbit
Copy link
Contributor Author

@leviding 修改完成

@leviding leviding added 标注 待管理员 Review and removed enhancement 等待译者修改 labels Jun 26, 2019
@lsvih lsvih merged commit f9056ac into xitu:master Jun 26, 2019
@lsvih
Copy link
Member

lsvih commented Jun 26, 2019

@EmilyQiRabbit 已经 merge 啦~ 快快麻溜发布到掘金然后给我发下链接,方便及时添加积分哟。

掘金翻译计划有自己的知乎专栏,你也可以投稿哈,推荐使用一个好用的插件
专栏地址:https://zhuanlan.zhihu.com/juejinfanyi

@lsvih lsvih added 翻译完成 and removed 标注 待管理员 Review labels Jun 26, 2019
@EmilyQiRabbit EmilyQiRabbit deleted the translation/classes-vs-data-structures branch July 8, 2019 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

类(Class)与数据结构(Data Structures)
6 participants