8000 bugfix:第 15 章翻译有点问题 by chelintsien · Pull Request #515 · lingcoder/OnJava8 · GitHub
[go: up one dir, main page]

Skip to content

bugfix:第 15 章翻译有点问题 #515

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

Merged
merged 3 commits into from
Jul 21, 2020

Conversation

chelintsien
Copy link
Contributor

原来:When you think about it, this is what you want to happen,
but if you must code all that logic yourself, you might miss something
and get it wrong. Imagine all the code that’s out there where the
programmers didn’t think through all the implications of cleanup, and
did it wrong. For that reason you should always use try-with-resources
whenever you can. It helps a lot that the feature also makes the
resulting code much cleaner and easier to understand

译文:即使 Closer.close() 抛出异常也是如此。仔细想想,这就是你想要的结果。但如果你必须自己编写所有的逻辑,你可能会错过一些东西,并把它弄错。想象一下那里所有的代码,程序员没有考虑清理的所有影响,并且做错了。

@@ -1890,7 +1890,7 @@ Caught: CloseException

从技术上讲,我们并没有被迫在这里提供一个 catch 子句;你可以通过 **main() throws CloseException** 的方式来报告异常。但 catch 子句是放置错误处理代码的典型位置。

请注意,因为所有三个对象都已创建,所以它们都以相反的顺序关闭 - 即使 Closer 也是如此。 close() 抛出异常。当你想到它时,这就是你想要发生的事情,但是如果你必须自己编写所有这些逻辑,那么你可能会错过一些错误。想象一下所有代码都在那里,程序员没有考虑清理的所有含义,并且做错了。因此,应始终尽可能使用 try-with-resources。它有助于实现该功能,使得生成的代码更清晰,更易于理解。
请注意,因为所有三个对象都已创建,所以它们都以相反的顺序关闭 - 即使 Closer.close() 抛出异常也是如此。仔细想想,这就是你想要的结果。但如果你必须自己编写所有的逻辑,你可能会错过一些东西,并把它弄错。想象一下那里所有的代码,程序员没有考虑清理的所有影响,并且做错了。因此,应始终尽可能使用 try-with-resources。它有助于实现该功能,使得生成的代码更清晰,更易于理解。
Copy link
Collaborator
@sjsdfg sjsdfg Jul 21, 2020

Choose a reason for hiding this comment

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

but if you must code all that logic yourself, you might miss something
and get it wrong.

但如果你必须亲手编写所有的逻辑,或许会丢失一些东西并使得逻辑出错。

Imagine all the code that’s out there where the
programmers didn’t think through all the implications of cleanup, and
did it wrong.

想想那些程序员没有考虑 Clean up 所有影响并且出错的代码。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

本人表达不是很好,用你翻译的来就行了,只是原来的翻译是有点问题的

Copy link
Collaborator
@sjsdfg sjsdfg Jul 21, 2020

Choose a reason for hiding this comment

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

你更新这个 PR,然后我合进去

Copy link
Contributor Author

Choose a reason for hiding this comment

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

你更新这个 PR,然后我合进去

已更新

@@ -1890,7 +1890,7 @@ Caught: CloseException

从技术上讲,我们并没有被迫在这里提供一个 catch 子句;你可以通过 **main() throws CloseException** 的方式来报告异常。但 catch 子句是放置错误处理代码的典型位置。

请注意,因为所有三个对象都已创建,所以它们都以相反的顺序关闭 - 即使 Closer 也是如此。 close() 抛出异常。当你想到它时,这就是你想要发生的事情,但是如果你必须自己编写所有这些 8000 辑,那么你可能会错过一些错误。想象一下所有代码都在那里,程序员没有考虑清理的所有含义,并且做错了。因此,应始终尽可能使用 try-with-resources。它有助于实现该功能,使得生成的代码更清晰,更易于理解。
请注意,因为所有三个对象都已创建,所以它们都以相反的顺序关闭 - 即使 Closer.close() 抛出异常也是如此。仔细想想,这就是你想要的结果。但如果你必须亲手编写所有的逻辑,或许会丢失一些东西并使得逻辑出错。想想那些程序员没有考虑 Clean up 的所有影响并且出错的代码。因此,应始终尽可能使用 try-with-resources。它有助于实现该功能,使得生成的代码更清晰,更易于理解。
Copy link
Collaborator

Choose a reason for hiding this comment

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

因此,应始终尽可能使用 try-with-resources。它有助于实现该功能,使得生成的代码更清晰,更易于理解。

这个英文原文是啥。

「始终尽可能」使用,这两个表示程度的词一起出现在中文是个病句。

贴出来咱们再一起看下

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For that reason you should always use try-with-resources
whenever you can. It helps a lot that the feature also makes the
resulting code much cleaner and easier to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这句“它有助于实现该功能” 也是有问题的

应该是这特性有助于。。。

Copy link
Collaborator

Choose a reason for hiding this comment

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

如果可以,你应当始终使用 try-with-resources。这个特性有助于生成更简洁,更易于理解的代码

Copy link
Collaborator

Choose a reason for hiding this comment

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

后面半句的翻译也是完全不对了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

后面半句的翻译也是完全不对了

已经更新为你上面发的译文了

翻译不对意
@sjsdfg sjsdfg changed the title 翻译有点问题 bugfix:第 15 章翻译有点问题 Jul 21, 2020
@sjsdfg sjsdfg merged commit d0bc327 into lingcoder:master Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0