{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/coding-standards/pulls/comments/40632319","id":40632319,"diff_hunk":"@@ -0,0 +1,580 @@\n+# Coding Style Guide\n+Tài liệu xây dựng trên tài liệu tham khảo và [Android Code Style Guidelines](https://source.android.com/source/code-style.html)\n+\n+## 1. Java language rules\n+\n+### 1.1 Đừng bỏ qua trường hợp ngoại lệ\n+\n+Bạn không bao giờ được làm như sau:\n+\n+```java\n+void setServerPort(String value) {\n+    try {\n+        serverPort = Integer.parseInt(value);\n+    } catch (NumberFormatException e) { }\n+}\n+```\n+\n+Theo bạn nghĩ nó có thể không bao giờ xảy ra, nhưng một ngày nào đó bạn của bạn sẽ gặp vấn đề này. Bạn phải buộc xử lý nó theo một số cách.\n+\n+* Ném ngoại lệ lên cho người gọi phương thức\n+\n+```java\n+void setServerPort(String value) throws NumberFormatException {\n+    serverPort = Integer.parseInt(value);\n+}\n+```\n+* Ném lại ngoại lệ với lớp trừu tượng của bạn\n+\n+```java\n+void setServerPort(String value) throws ConfigurationException {\n+    try {\n+        serverPort = Integer.parseInt(value);\n+    } catch (NumberFormatException e) {\n+        throw new ConfigurationException(\"Port \" + value + \" is not valid.\");\n+    }\n+}\n+```\n+* Thay thế một giá trị thích hợp, như giá trị mặc định chẳng hạn\n+\n+```java\n+void setServerPort(String value) {\n+    try {\n+        serverPort = Integer.parseInt(value);\n+    } catch (NumberFormatException e) {\n+        serverPort = 80;  // default port for server \n+    }\n+}\n+```\n+\n+* Ném ngoại lệ vào một RuntimeException mới. Nhưng bạn chắc chắn rằng bạn muốn làm điều này, vì nó sẽ gây lỗi ứng dụng\n+\n+```java\n+void setServerPort(String value) {\n+    try {\n+        serverPort = Integer.parseInt(value);\n+    } catch (NumberFormatException e) {\n+        throw new RuntimeException(\"port \" + value \" is invalid, \", e);\n+    }\n+}\n+```\n+\n+* Cuối cùng bạn sẽ loại bỏ nó nhưng phải có một lý do chính đáng\n+\n+```java\n+void setServerPort(String value) {\n+    try {\n+        serverPort = Integer.parseInt(value);\n+    } catch (NumberFormatException e) {\n+        // Method is documented to just ignore invalid user input.\n+        // serverPort will just be unchanged.\n+    }\n+}\n+```\n+\n+### 1.2 Không được bắt ngoại lệ chung\n+\n+```java\n+try {\n+    someComplicatedIOFunction();        // may throw IOException \n+    someComplicatedParsingFunction();   // may throw ParsingException \n+    someComplicatedSecurityFunction();  // may throw SecurityException \n+    // phew, made it all the way \n+} catch (Exception e) {                 // I'll just catch all exceptions \n+    handleError();                      // with one generic handler!\n+}\n+```\n+\n+Xem thêm tại [đây](https://source.android.com/source/code-style.html#dont-catch-generic-exception)\n+\n+### 1.3 Không sử dụng finalizers\n+\n+Xem tại đây [Android code style guidelines](https://source.android.com/source/code-style.html#dont-use-finalizers)\n+\n+### 1.4 Fully qualify imports\n+\n+Không tốt: `import foo.*;`\n+\n+Tốt: `import foo.Bar;`\n+\n+Xem thêm [tại đây](https://source.android.com/source/code-style.html#fully-qualify-imports)\n+\n+## 2 Java style rules\n+\n+### 2.1 Định nghĩa và đặt tên\n+\n+Các trường cần được định nghĩa ở đầu file và tuân theo cú pháp đặt tên như sau.\n+\n+* Private, non-static tên trường bắt đầu bằng chữ __m__.\n+* Private, static tên trường bắt đầu bằng chữ s __s__.","path":"vn/android/codingstyleguide.md","position":109,"original_position":109,"commit_id":"2b3f29ba24c26ceec6e0fe7f0eb9c923b3160b2a","original_commit_id":"2b3f29ba24c26ceec6e0fe7f0eb9c923b3160b2a","user":{"login":"KaKaVip","id":1430683,"avatar_url":"https://avatars.githubusercontent.com/u/1430683?v=3","gravatar_id":"","url":"https://api.github.com/users/KaKaVip","html_url":"https://github.com/KaKaVip","followers_url":"https://api.github.com/users/KaKaVip/followers","following_url":"https://api.github.com/users/KaKaVip/following{/other_user}","gists_url":"https://api.github.com/users/KaKaVip/gists{/gist_id}","starred_url":"https://api.github.com/users/KaKaVip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KaKaVip/subscriptions","organizations_url":"https://api.github.com/users/KaKaVip/orgs","repos_url":"https://api.github.com/users/KaKaVip/repos","events_url":"https://api.github.com/users/KaKaVip/events{/privacy}","received_events_url":"https://api.github.com/users/KaKaVip/received_events","type":"User","site_admin":false},"body":":+1: ","created_at":"2015-09-29T03:43:52Z","updated_at":"2015-09-29T03:43:52Z","html_url":"https://github.com/framgia/coding-standards/pull/93#discussion_r40632319","pull_request_url":"https://api.github.com/repos/framgia/coding-standards/pulls/93","_links":{"self":{"href":"https://api.github.com/repos/framgia/coding-standards/pulls/comments/40632319"},"html":{"href":"https://github.com/framgia/coding-standards/pull/93#discussion_r40632319"},"pull_request":{"href":"https://api.github.com/repos/framgia/coding-standards/pulls/93"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/coding-standards/pulls/93","id":46128384,"html_url":"https://github.com/framgia/coding-standards/pull/93","diff_url":"https://github.com/framgia/coding-standards/pull/93.diff","patch_url":"https://github.com/framgia/coding-standards/pull/93.patch","issue_url":"https://api.github.com/repos/framgia/coding-standards/issues/93","number":93,"state":"closed","locked":false,"title":"Add new Android Coding Standard","user":{"login":"KaKaVip","id":1430683,"avatar_url":"https://avatars.githubusercontent.com/u/1430683?v=3","gravatar_id":"","url":"https://api.github.com/users/KaKaVip","html_url":"https://github.com/KaKaVip","followers_url":"https://api.github.com/users/KaKaVip/followers","following_url":"https://api.github.com/users/KaKaVip/following{/other_user}","gists_url":"https://api.github.com/users/KaKaVip/gists{/gist_id}","starred_url":"https://api.github.com/users/KaKaVip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KaKaVip/subscriptions","organizations_url":"https://api.github.com/users/KaKaVip/orgs","repos_url":"https://api.github.com/users/KaKaVip/repos","events_url":"https://api.github.com/users/KaKaVip/events{/privacy}","received_events_url":"https://api.github.com/users/KaKaVip/received_events","type":"User","site_admin":false},"body":"[Preview](https://github.com/KaKaVip/coding-standards/blob/master/vn/README.md#android)\r\nPhiên bản tiếng Việt","created_at":"2015-09-28T07:51:23Z","updated_at":"2015-09-29T03:43:52Z","closed_at":"2015-09-29T03:16:04Z","merged_at":"2015-09-29T03:16:04Z","merge_commit_sha":"2ddf269181e09ff858c1eb07d078d6ef60a8b452","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framgia/coding-standards/pulls/93/commits","review_comments_url":"https://api.github.com/repos/framgia/coding-standards/pulls/93/comments","review_comment_url":"https://api.github.com/repos/framgia/coding-standards/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/coding-standards/issues/93/comments","statuses_url":"https://api.github.com/repos/framgia/coding-standards/statuses/2b3f29ba24c26ceec6e0fe7f0eb9c923b3160b2a","head":{"label":"KaKaVip:master","ref":"master","sha":"2b3f29ba24c26ceec6e0fe7f0eb9c923b3160b2a","user":{"login":"KaKaVip","id":1430683,"avatar_url":"https://avatars.githubusercontent.com/u/1430683?v=3","gravatar_id":"","url":"https://api.github.com/users/KaKaVip","html_url":"https://github.com/KaKaVip","followers_url":"https://api.github.com/users/KaKaVip/followers","following_url":"https://api.github.com/users/KaKaVip/following{/other_user}","gists_url":"https://api.github.com/users/KaKaVip/gists{/gist_id}","starred_url":"https://api.github.com/users/KaKaVip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KaKaVip/subscriptions","organizations_url":"https://api.github.com/users/KaKaVip/orgs","repos_url":"https://api.github.com/users/KaKaVip/repos","events_url":"https://api.github.com/users/KaKaVip/events{/privacy}","received_events_url":"https://api.github.com/users/KaKaVip/received_events","type":"User","site_admin":false},"repo":{"id":43278296,"name":"coding-standards","full_name":"KaKaVip/coding-standards","owner":{"login":"KaKaVip","id":1430683,"avatar_url":"https://avatars.githubusercontent.com/u/1430683?v=3","gravatar_id":"","url":"https://api.github.com/users/KaKaVip","html_url":"https://github.com/KaKaVip","followers_url":"https://api.github.com/users/KaKaVip/followers","following_url":"https://api.github.com/users/KaKaVip/following{/other_user}","gists_url":"https://api.github.com/users/KaKaVip/gists{/gist_id}","starred_url":"https://api.github.com/users/KaKaVip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KaKaVip/subscriptions","organizations_url":"https://api.github.com/users/KaKaVip/orgs","repos_url":"https://api.github.com/users/KaKaVip/repos","events_url":"https://api.github.com/users/KaKaVip/events{/privacy}","received_events_url":"https://api.github.com/users/KaKaVip/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KaKaVip/coding-standards","description":"Framgia's coding standards","fork":true,"url":"https://api.github.com/repos/KaKaVip/coding-standards","forks_url":"https://api.github.com/repos/KaKaVip/coding-standards/forks","keys_url":"https://api.github.com/repos/KaKaVip/coding-standards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KaKaVip/coding-standards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KaKaVip/coding-standards/teams","hooks_url":"https://api.github.com/repos/KaKaVip/coding-standards/hooks","issue_events_url":"https://api.github.com/repos/KaKaVip/coding-standards/issues/events{/number}","events_url":"https://api.github.com/repos/KaKaVip/coding-standards/events","assignees_url":"https://api.github.com/repos/KaKaVip/coding-standards/assignees{/user}","branches_url":"https://api.github.com/repos/KaKaVip/coding-standards/branches{/branch}","tags_url":"https://api.github.com/repos/KaKaVip/coding-standards/tags","blobs_url":"https://api.github.com/repos/KaKaVip/coding-standards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KaKaVip/coding-standards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KaKaVip/coding-standards/git/refs{/sha}","trees_url":"https://api.github.com/repos/KaKaVip/coding-standards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KaKaVip/coding-standards/statuses/{sha}","languages_url":"https://api.github.com/repos/KaKaVip/coding-standards/languages","stargazers_url":"https://api.github.com/repos/KaKaVip/coding-standards/stargazers","contributors_url":"https://api.github.com/repos/KaKaVip/coding-standards/contributors","subscribers_url":"https://api.github.com/repos/KaKaVip/coding-standards/subscribers","subscription_url":"https://api.github.com/repos/KaKaVip/coding-standards/subscription","commits_url":"https://api.github.com/repos/KaKaVip/coding-standards/commits{/sha}","git_commits_url":"https://api.github.com/repos/KaKaVip/coding-standards/git/commits{/sha}","comments_url":"https://api.github.com/repos/KaKaVip/coding-standards/comments{/number}","issue_comment_url":"https://api.github.com/repos/KaKaVip/coding-standards/issues/comments{/number}","contents_url":"https://api.github.com/repos/KaKaVip/coding-standards/contents/{+path}","compare_url":"https://api.github.com/repos/KaKaVip/coding-standards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KaKaVip/coding-standards/merges","archive_url":"https://api.github.com/repos/KaKaVip/coding-standards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KaKaVip/coding-standards/downloads","issues_url":"https://api.github.com/repos/KaKaVip/coding-standards/issues{/number}","pulls_url":"https://api.github.com/repos/KaKaVip/coding-standards/pulls{/number}","milestones_url":"https://api.github.com/repos/KaKaVip/coding-standards/milestones{/number}","notifications_url":"https://api.github.com/repos/KaKaVip/coding-standards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KaKaVip/coding-standards/labels{/name}","releases_url":"https://api.github.com/repos/KaKaVip/coding-standards/releases{/id}","created_at":"2015-09-28T03:38:59Z","updated_at":"2015-08-31T18:29:27Z","pushed_at":"2015-09-29T03:37:29Z","git_url":"git://github.com/KaKaVip/coding-standards.git","ssh_url":"git@github.com:KaKaVip/coding-standards.git","clone_url":"https://github.com/KaKaVip/coding-standards.git","svn_url":"https://github.com/KaKaVip/coding-standards","homepage":null,"size":692,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"framgia:master","ref":"master","sha":"e7c3839816e9ee3d7d7acec2d288cc05d8980cea","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":9210682,"name":"coding-standards","full_name":"framgia/coding-standards","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/coding-standards","description":"Framgia's coding standards","fork":false,"url":"https://api.github.com/repos/framgia/coding-standards","forks_url":"https://api.github.com/repos/framgia/coding-standards/forks","keys_url":"https://api.github.com/repos/framgia/coding-standards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/coding-standards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/coding-standards/teams","hooks_url":"https://api.github.com/repos/framgia/coding-standards/hooks","issue_events_url":"https://api.github.com/repos/framgia/coding-standards/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/coding-standards/events","assignees_url":"https://api.github.com/repos/framgia/coding-standards/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/coding-standards/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/coding-standards/tags","blobs_url":"https://api.github.com/repos/framgia/coding-standards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/coding-standards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/coding-standards/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/coding-standards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/coding-standards/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/coding-standards/languages","stargazers_url":"https://api.github.com/repos/framgia/coding-standards/stargazers","contributors_url":"https://api.github.com/repos/framgia/coding-standards/contributors","subscribers_url":"https://api.github.com/repos/framgia/coding-standards/subscribers","subscription_url":"https://api.github.com/repos/framgia/coding-standards/subscription","commits_url":"https://api.github.com/repos/framgia/coding-standards/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/coding-standards/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/coding-standards/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/coding-standards/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/coding-standards/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/coding-standards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/coding-standards/merges","archive_url":"https://api.github.com/repos/framgia/coding-standards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/coding-standards/downloads","issues_url":"https://api.github.com/repos/framgia/coding-standards/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/coding-standards/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/coding-standards/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/coding-standards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/coding-standards/labels{/name}","releases_url":"https://api.github.com/repos/framgia/coding-standards/releases{/id}","created_at":"2013-04-04T04:00:28Z","updated_at":"2015-08-31T18:29:27Z","pushed_at":"2015-09-29T03:16:05Z","git_url":"git://github.com/framgia/coding-standards.git","ssh_url":"git@github.com:framgia/coding-standards.git","clone_url":"https://github.com/framgia/coding-standards.git","svn_url":"https://github.com/framgia/coding-standards","homepage":null,"size":692,"stargazers_count":21,"watchers_count":21,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":67,"mirror_url":null,"open_issues_count":2,"forks":67,"open_issues":2,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/coding-standards/pulls/93"},"html":{"href":"https://github.com/framgia/coding-standards/pull/93"},"issue":{"href":"https://api.github.com/repos/framgia/coding-standards/issues/93"},"comments":{"href":"https://api.github.com/repos/framgia/coding-standards/issues/93/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/coding-standards/pulls/93/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/coding-standards/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/coding-standards/pulls/93/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/coding-standards/statuses/2b3f29ba24c26ceec6e0fe7f0eb9c923b3160b2a"}}}}