{"action":"created","comment":{"url":"https://api.github.com/repos/xitu/gold-miner/pulls/comments/177164213","pull_request_review_id":106984816,"id":177164213,"diff_hunk":"@@ -5,53 +5,53 @@\n > * 译者：\n > * 校对者：\n \n-# Good Coding Practices – Five Tips to Enhance Code Quality\n+# 良好的编码习惯 — 5 个提高代码质量的技巧\n \n-Good coding practices are like a bright beacon guiding unwary developers to the shore at night. Good code is predictable. Easy to debug, extend and test.\n+良好的编码习惯像黑夜中的一盏明灯，指引着迷路的开发者安全靠岸。良好的代码是可预测的，是易于调试、扩展和测试的。\n \n-Good coding practices help your teammates become more productive and makes working with your code base an overall pleasant experience.\n+良好的编码习惯能够提高你同事的工作效率，同时让你的代码库从整体上给人一种愉快的阅读体验。\n \n-What I will share with you are five universal good coding practices that will improve the readability, extensibility and overall value of your code. The sooner you understand and apply these principles, the greater the benefits will be.\n+接下来我要和你们分享的是 5 个通用的良好编码习惯，它们能提高你代码的可读性，可扩展性和整体质量。越快理解和运用这些准则，你的收益就越大。\n \n-Let’s get started.\n+让我们开始吧。\n \n-## Why Good Coding Practices?\n+## 为什么要有良好的编码习惯?\n \n-Learning and applying good coding practices is like investing in stocks that you know, for sure, will rise exponentially. In other words, as long as you invest that lump sum right now, the returns you get, years or even months down the track will far outweigh what you put in now.\n+学习和运用良好的编码习惯就像投资那些你知道一定会成倍增长的股票。换句话说，你只要现在做一次性的投资，在接下来的几年甚至几个月的收益和回报，将会远远超过你现在的投入。\n \n-Developers at all stages in their journey will benefit from applying and learning good coding practices. And as I mentioned before, the sooner you start applying them, the better. Now is the best time to learn and integrate good coding practices into your current projects.\n+处于职业生涯任何阶段的开发者都会受益于应用和学习良好的编码习惯。就像我上面所说，你越早开始使用它们，你的收益便越大。现在便是最好的时机来学习和将良好的编码习惯应用于你现在的项目。\n \n-I aimed to present these points so that they build on each other, and make sense as both individual pieces of advice and as a cohesive unit.\n+我提出这些观点，旨在它们能够互相支撑，且无论是作为单独的建议还是组合起来都是合理的。\n \n-## 1. Name Methods and Variables Succinctly\n+## 1. 简洁地给方法和变量命名\n \n-When naming classes, variables, and methods, it can be very tempting to give names to our methods out of impulse. Especially when everything makes a lot of sense in your head. Try coming back to that code a few months down the line and see if it makes sense to you. If it does, chances are, you named your variables and methods wisely.\n+当给类、变量和方法命名时，我们很容易冲动地给我们的方法命名。特别是当你觉得这一切都很合理时。试着几个月之后再回头看看那些代码，看看它们是否依旧合理。如果是，那么很有可能是你当时明智地命名了你的变量和方法。\n \n-[![good coding practices - method names are like headings and sentences in an article](//personalzone-hulgokm2zfcmm9u.netdna-ssl.com/wp-content/uploads/2017/07/good-coding-practices-method-names-are-like-heading-sentences.jpg)](//personalzone-hulgokm2zfcmm9u.netdna-ssl.com/wp-content/uploads/2017/07/good-coding-practices-method-names-are-like-heading-sentences.jpg)\n+[![良好的编码习惯 —— 方法名类似文章中的标题和句子](//personalzone-hulgokm2zfcmm9u.netdna-ssl.com/wp-content/uploads/2017/07/good-coding-practices-method-names-are-like-heading-sentences.jpg)](//personalzone-hulgokm2zfcmm9u.netdna-ssl.com/wp-content/uploads/2017/07/good-coding-practices-method-names-are-like-heading-sentences.jpg)\n \n-Methods are like headings or sentences in an article.\n+方法名类似文章中的标题和句子。\n \n-Therefore, when naming methods, aim to give names that accurately summarize the contents of the method. If the method name becomes too long or vague, it is an indicator that the method is doing way too many things.\n+因此，当给方法命名时，要能够准确概括方法的内容。如果方法名变得太长或模糊，那么表示该方法做了太多的事情。\n \n-The code that you write inside of a method body is the words that make up the sentence.\n+方法中的内容组成了方法名。\n \n-When looking at an article, what stands out to you the most? Generally, it is the heading that stands out the most. Well, in a program, **key methods are like headings**. When writing an article for a high school or college essay, do you just write some random string of words and finalize the heading without a second thought?\n+当你阅读一篇文章时，你觉得最突出的是什么？通常，最突出的是标题。在程序中，**关键方法就像标题**。当你为高中或大学散文写投稿文章时，你是否只是随便瞎写几句，然后不假思索地写完标题？\n \n-> A simple, intuitive method name is worth a thousand words.\n+> 一个简单直观的方法名胜过千言万语。\n \n-Naturally, the choice of words in the sentence and how they are packaged together is also important. This is why we also need to be intentional on how we name our variables. Most of the time, before looking at the logic, people try to grasp the big-picture view of the implementation detail by reading the variable names in each line of logic.\n+当然，句子中单词的选择以及如何将它们组合在一起也很重要。这就是为什么我们也需要特意地给我们的变量命名。大多数情况下，在查看代码逻辑之前，人们会试图通过阅读每一行中的变量名来对代码实现细节的有一个整体把握。\n \n-Make sure that both methods and variable names are clear and accurately describe what is going on. Imagine if you gave a tourist the wrong direction, just how mad and confused he/she will be. You are giving directions to the next programmer who comes around to read your code.\n+确保方法和变量名称都是清晰明了的，且准确地描述了正在发生的事情。想象一下，如果你指引给一个游客错误的方向，他/她会多么生气和困惑。你正在为下一个前来阅读您的代码的程序员指引道路。","path":"TODO1/good-coding-practices-tips-enhance-code-quality.md","position":59,"original_position":59,"commit_id":"5f1821ce1775f9acaf37dea4653a9dcf32ddae7b","original_commit_id":"5f1821ce1775f9acaf37dea4653a9dcf32ddae7b","user":{"login":"dandyxu","id":10475793,"avatar_url":"https://avatars2.githubusercontent.com/u/10475793?v=4","gravatar_id":"","url":"https://api.github.com/users/dandyxu","html_url":"https://github.com/dandyxu","followers_url":"https://api.github.com/users/dandyxu/followers","following_url":"https://api.github.com/users/dandyxu/following{/other_user}","gists_url":"https://api.github.com/users/dandyxu/gists{/gist_id}","starred_url":"https://api.github.com/users/dandyxu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dandyxu/subscriptions","organizations_url":"https://api.github.com/users/dandyxu/orgs","repos_url":"https://api.github.com/users/dandyxu/repos","events_url":"https://api.github.com/users/dandyxu/events{/privacy}","received_events_url":"https://api.github.com/users/dandyxu/received_events","type":"User","site_admin":false},"body":"[你正在为下一个前来阅读您的代码的程序员指引道路] => [你正在为下一个前来阅读你代码的程序员指引道路]，去除一个\"的\"，会更通顺一些。","created_at":"2018-03-26T17:01:31Z","updated_at":"2018-03-26T17:25:25Z","html_url":"https://github.com/xitu/gold-miner/pull/3531#discussion_r177164213","pull_request_url":"https://api.github.com/repos/xitu/gold-miner/pulls/3531","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/comments/177164213"},"html":{"href":"https://github.com/xitu/gold-miner/pull/3531#discussion_r177164213"},"pull_request":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/3531"}}},"pull_request":{"url":"https://api.github.com/repos/xitu/gold-miner/pulls/3531","id":177438121,"html_url":"https://github.com/xitu/gold-miner/pull/3531","diff_url":"https://github.com/xitu/gold-miner/pull/3531.diff","patch_url":"https://github.com/xitu/gold-miner/pull/3531.patch","issue_url":"https://api.github.com/repos/xitu/gold-miner/issues/3531","number":3531,"state":"open","locked":false,"title":"良好的编码习惯 — 5 个提高代码质量的技巧","user":{"login":"NeoyeElf","id":6872731,"avatar_url":"https://avatars0.githubusercontent.com/u/6872731?v=4","gravatar_id":"","url":"https://api.github.com/users/NeoyeElf","html_url":"https://github.com/NeoyeElf","followers_url":"https://api.github.com/users/NeoyeElf/followers","following_url":"https://api.github.com/users/NeoyeElf/following{/other_user}","gists_url":"https://api.github.com/users/NeoyeElf/gists{/gist_id}","starred_url":"https://api.github.com/users/NeoyeElf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeoyeElf/subscriptions","organizations_url":"https://api.github.com/users/NeoyeElf/orgs","repos_url":"https://api.github.com/users/NeoyeElf/repos","events_url":"https://api.github.com/users/NeoyeElf/events{/privacy}","received_events_url":"https://api.github.com/users/NeoyeElf/received_events","type":"User","site_admin":false},"body":"译文翻译完成，resolve #3506 \r\n","created_at":"2018-03-26T12:59:48Z","updated_at":"2018-03-26T17:25:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6fc109c3165bbf65ba37b44a484a1adb1db233f9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":772337125,"url":"https://api.github.com/repos/xitu/gold-miner/labels/%E5%85%B6%E4%BB%96","name":"其他","color":"5319e7","default":false},{"id":329563971,"url":"https://api.github.com/repos/xitu/gold-miner/labels/%E6%A0%A1%E5%AF%B9%E8%AE%A4%E9%A2%86","name":"校对认领","color":"ff5722","default":false},{"id":322084033,"url":"https://api.github.com/repos/xitu/gold-miner/labels/%E6%AD%A3%E5%9C%A8%E6%A0%A1%E5%AF%B9","name":"正在校对","color":"c2e0c6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/xitu/gold-miner/pulls/3531/commits","review_comments_url":"https://api.github.com/repos/xitu/gold-miner/pulls/3531/comments","review_comment_url":"https://api.github.com/repos/xitu/gold-miner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xitu/gold-miner/issues/3531/comments","statuses_url":"https://api.github.com/repos/xitu/gold-miner/statuses/5f1821ce1775f9acaf37dea4653a9dcf32ddae7b","head":{"label":"NeoyeElf:translation/Good-Coding-Practices-–-Five-Tips-to-Enhance-Code-Quality","ref":"translation/Good-Coding-Practices-–-Five-Tips-to-Enhance-Code-Quality","sha":"5f1821ce1775f9acaf37dea4653a9dcf32ddae7b","user":{"login":"NeoyeElf","id":6872731,"avatar_url":"https://avatars0.githubusercontent.com/u/6872731?v=4","gravatar_id":"","url":"https://api.github.com/users/NeoyeElf","html_url":"https://github.com/NeoyeElf","followers_url":"https://api.github.com/users/NeoyeElf/followers","following_url":"https://api.github.com/users/NeoyeElf/following{/other_user}","gists_url":"https://api.github.com/users/NeoyeElf/gists{/gist_id}","starred_url":"https://api.github.com/users/NeoyeElf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeoyeElf/subscriptions","organizations_url":"https://api.github.com/users/NeoyeElf/orgs","repos_url":"https://api.github.com/users/NeoyeElf/repos","events_url":"https://api.github.com/users/NeoyeElf/events{/privacy}","received_events_url":"https://api.github.com/users/NeoyeElf/received_events","type":"User","site_admin":false},"repo":{"id":118388695,"name":"gold-miner","full_name":"NeoyeElf/gold-miner","owner":{"login":"NeoyeElf","id":6872731,"avatar_url":"https://avatars0.githubusercontent.com/u/6872731?v=4","gravatar_id":"","url":"https://api.github.com/users/NeoyeElf","html_url":"https://github.com/NeoyeElf","followers_url":"https://api.github.com/users/NeoyeElf/followers","following_url":"https://api.github.com/users/NeoyeElf/following{/other_user}","gists_url":"https://api.github.com/users/NeoyeElf/gists{/gist_id}","starred_url":"https://api.github.com/users/NeoyeElf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeoyeElf/subscriptions","organizations_url":"https://api.github.com/users/NeoyeElf/orgs","repos_url":"https://api.github.com/users/NeoyeElf/repos","events_url":"https://api.github.com/users/NeoyeElf/events{/privacy}","received_events_url":"https://api.github.com/users/NeoyeElf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NeoyeElf/gold-miner","description":"🥇掘金翻译计划，可能是世界最大最好的英译中技术社区，最懂读者和译者的翻译平台：","fork":true,"url":"https://api.github.com/repos/NeoyeElf/gold-miner","forks_url":"https://api.github.com/repos/NeoyeElf/gold-miner/forks","keys_url":"https://api.github.com/repos/NeoyeElf/gold-miner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NeoyeElf/gold-miner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NeoyeElf/gold-miner/teams","hooks_url":"https://api.github.com/repos/NeoyeElf/gold-miner/hooks","issue_events_url":"https://api.github.com/repos/NeoyeElf/gold-miner/issues/events{/number}","events_url":"https://api.github.com/repos/NeoyeElf/gold-miner/events","assignees_url":"https://api.github.com/repos/NeoyeElf/gold-miner/assignees{/user}","branches_url":"https://api.github.com/repos/NeoyeElf/gold-miner/branches{/branch}","tags_url":"https://api.github.com/repos/NeoyeElf/gold-miner/tags","blobs_url":"https://api.github.com/repos/NeoyeElf/gold-miner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NeoyeElf/gold-miner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NeoyeElf/gold-miner/git/refs{/sha}","trees_url":"https://api.github.com/repos/NeoyeElf/gold-miner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NeoyeElf/gold-miner/statuses/{sha}","languages_url":"https://api.github.com/repos/NeoyeElf/gold-miner/languages","stargazers_url":"https://api.github.com/repos/NeoyeElf/gold-miner/stargazers","contributors_url":"https://api.github.com/repos/NeoyeElf/gold-miner/contributors","subscribers_url":"https://api.github.com/repos/NeoyeElf/gold-miner/subscribers","subscription_url":"https://api.github.com/repos/NeoyeElf/gold-miner/subscription","commits_url":"https://api.github.com/repos/NeoyeElf/gold-miner/commits{/sha}","git_commits_url":"https://api.github.com/repos/NeoyeElf/gold-miner/git/commits{/sha}","comments_url":"https://api.github.com/repos/NeoyeElf/gold-miner/comments{/number}","issue_comment_url":"https://api.github.com/repos/NeoyeElf/gold-miner/issues/comments{/number}","contents_url":"https://api.github.com/repos/NeoyeElf/gold-miner/contents/{+path}","compare_url":"https://api.github.com/repos/NeoyeElf/gold-miner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NeoyeElf/gold-miner/merges","archive_url":"https://api.github.com/repos/NeoyeElf/gold-miner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NeoyeElf/gold-miner/downloads","issues_url":"https://api.github.com/repos/NeoyeElf/gold-miner/issues{/number}","pulls_url":"https://api.github.com/repos/NeoyeElf/gold-miner/pulls{/number}","milestones_url":"https://api.github.com/repos/NeoyeElf/gold-miner/milestones{/number}","notifications_url":"https://api.github.com/repos/NeoyeElf/gold-miner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NeoyeElf/gold-miner/labels{/name}","releases_url":"https://api.github.com/repos/NeoyeElf/gold-miner/releases{/id}","deployments_url":"https://api.github.com/repos/NeoyeElf/gold-miner/deployments","created_at":"2018-01-22T01:02:22Z","updated_at":"2018-03-26T12:38:08Z","pushed_at":"2018-03-26T12:58:46Z","git_url":"git://github.com/NeoyeElf/gold-miner.git","ssh_url":"git@github.com:NeoyeElf/gold-miner.git","clone_url":"https://github.com/NeoyeElf/gold-miner.git","svn_url":"https://github.com/NeoyeElf/gold-miner","homepage":"https://juejin.im/tag/掘金翻译计划","size":30939,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"xitu:master","ref":"master","sha":"6202a57ac1bb8e90df21cbe369d3e5945540ed6a","user":{"login":"xitu","id":10482599,"avatar_url":"https://avatars2.githubusercontent.com/u/10482599?v=4","gravatar_id":"","url":"https://api.github.com/users/xitu","html_url":"https://github.com/xitu","followers_url":"https://api.github.com/users/xitu/followers","following_url":"https://api.github.com/users/xitu/following{/other_user}","gists_url":"https://api.github.com/users/xitu/gists{/gist_id}","starred_url":"https://api.github.com/users/xitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xitu/subscriptions","organizations_url":"https://api.github.com/users/xitu/orgs","repos_url":"https://api.github.com/users/xitu/repos","events_url":"https://api.github.com/users/xitu/events{/privacy}","received_events_url":"https://api.github.com/users/xitu/received_events","type":"Organization","site_admin":false},"repo":{"id":45512989,"name":"gold-miner","full_name":"xitu/gold-miner","owner":{"login":"xitu","id":10482599,"avatar_url":"https://avatars2.githubusercontent.com/u/10482599?v=4","gravatar_id":"","url":"https://api.github.com/users/xitu","html_url":"https://github.com/xitu","followers_url":"https://api.github.com/users/xitu/followers","following_url":"https://api.github.com/users/xitu/following{/other_user}","gists_url":"https://api.github.com/users/xitu/gists{/gist_id}","starred_url":"https://api.github.com/users/xitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xitu/subscriptions","organizations_url":"https://api.github.com/users/xitu/orgs","repos_url":"https://api.github.com/users/xitu/repos","events_url":"https://api.github.com/users/xitu/events{/privacy}","received_events_url":"https://api.github.com/users/xitu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xitu/gold-miner","description":"🥇掘金翻译计划，可能是世界最大最好的英译中技术社区，最懂读者和译者的翻译平台：","fork":false,"url":"https://api.github.com/repos/xitu/gold-miner","forks_url":"https://api.github.com/repos/xitu/gold-miner/forks","keys_url":"https://api.github.com/repos/xitu/gold-miner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xitu/gold-miner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xitu/gold-miner/teams","hooks_url":"https://api.github.com/repos/xitu/gold-miner/hooks","issue_events_url":"https://api.github.com/repos/xitu/gold-miner/issues/events{/number}","events_url":"https://api.github.com/repos/xitu/gold-miner/events","assignees_url":"https://api.github.com/repos/xitu/gold-miner/assignees{/user}","branches_url":"https://api.github.com/repos/xitu/gold-miner/branches{/branch}","tags_url":"https://api.github.com/repos/xitu/gold-miner/tags","blobs_url":"https://api.github.com/repos/xitu/gold-miner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xitu/gold-miner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xitu/gold-miner/git/refs{/sha}","trees_url":"https://api.github.com/repos/xitu/gold-miner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xitu/gold-miner/statuses/{sha}","languages_url":"https://api.github.com/repos/xitu/gold-miner/languages","stargazers_url":"https://api.github.com/repos/xitu/gold-miner/stargazers","contributors_url":"https://api.github.com/repos/xitu/gold-miner/contributors","subscribers_url":"https://api.github.com/repos/xitu/gold-miner/subscribers","subscription_url":"https://api.github.com/repos/xitu/gold-miner/subscription","commits_url":"https://api.github.com/repos/xitu/gold-miner/commits{/sha}","git_commits_url":"https://api.github.com/repos/xitu/gold-miner/git/commits{/sha}","comments_url":"https://api.github.com/repos/xitu/gold-miner/comments{/number}","issue_comment_url":"https://api.github.com/repos/xitu/gold-miner/issues/comments{/number}","contents_url":"https://api.github.com/repos/xitu/gold-miner/contents/{+path}","compare_url":"https://api.github.com/repos/xitu/gold-miner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xitu/gold-miner/merges","archive_url":"https://api.github.com/repos/xitu/gold-miner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xitu/gold-miner/downloads","issues_url":"https://api.github.com/repos/xitu/gold-miner/issues{/number}","pulls_url":"https://api.github.com/repos/xitu/gold-miner/pulls{/number}","milestones_url":"https://api.github.com/repos/xitu/gold-miner/milestones{/number}","notifications_url":"https://api.github.com/repos/xitu/gold-miner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xitu/gold-miner/labels{/name}","releases_url":"https://api.github.com/repos/xitu/gold-miner/releases{/id}","deployments_url":"https://api.github.com/repos/xitu/gold-miner/deployments","created_at":"2015-11-04T03:29:13Z","updated_at":"2018-03-26T16:41:41Z","pushed_at":"2018-03-26T14:41:49Z","git_url":"git://github.com/xitu/gold-miner.git","ssh_url":"git@github.com:xitu/gold-miner.git","clone_url":"https://github.com/xitu/gold-miner.git","svn_url":"https://github.com/xitu/gold-miner","homepage":"https://juejin.im/tag/掘金翻译计划","size":30938,"stargazers_count":12677,"watchers_count":12677,"language":null,"has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2274,"mirror_url":null,"archived":false,"open_issues_count":33,"license":null,"forks":2274,"open_issues":33,"watchers":12677,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/3531"},"html":{"href":"https://github.com/xitu/gold-miner/pull/3531"},"issue":{"href":"https://api.github.com/repos/xitu/gold-miner/issues/3531"},"comments":{"href":"https://api.github.com/repos/xitu/gold-miner/issues/3531/comments"},"review_comments":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/3531/comments"},"review_comment":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xitu/gold-miner/pulls/3531/commits"},"statuses":{"href":"https://api.github.com/repos/xitu/gold-miner/statuses/5f1821ce1775f9acaf37dea4653a9dcf32ddae7b"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"dandyxu"}}