@@ -2,7 +2,7 @@ Original Repository: [ryanmcdermott/clean-code-javascript](https://github.com/ry
2
2
3
3
# clean-code-javascript
4
4
5
- ## Table of Contents
5
+ ## Mục lục
6
6
1 . [ Introduction] ( #introduction )
7
7
2 . [ Biến] ( #biến )
8
8
3 . [ Functions] ( #functions )
@@ -12,8 +12,8 @@ Original Repository: [ryanmcdermott/clean-code-javascript](https://github.com/ry
12
12
7 . [ Concurrency] ( #concurrency )
13
13
8 . [ Error Handling] ( #error-handling )
14
14
9 . [ Formatting] ( #formatting )
15
- 10 . [ Comments ] ( #comments )
16
- 11 . [ Translation ] ( #translation )
15
+ 10 . [ Viết chú thích ] ( #viết-chú-thích )
16
+ 11 . [ Các ngôn ngữ khác ] ( #các-ngôn-ngữ-khác )
17
17
18
18
## Introduction
19
19
![ Humorous image of software quality estimation as a count of how many expletives
@@ -2048,32 +2048,33 @@ review.perfReview();
2048
2048
2049
2049
** [ ⬆ back to top] ( #table-of-contents ) **
2050
2050
2051
- ## ** Comments**
2052
- ### Only comment things that have business logic complexity.
2053
- Comments are an apology, not a requirement. Good code * mostly* documents itself.
2051
+ ## ** Viết chú thích**
2052
+ ### Chỉ nên viết chú thích cho những thứ có logic phức tạp.
2053
+ Các chú thích thường là lời xin lỗi, chứ không phải là yêu cầu.
2054
+ Những đoạn code tốt thì * đa số* tự nó đã là tài liệu rồi.
2054
2055
2055
- ** Bad :**
2056
+ ** Không tốt :**
2056
2057
``` javascript
2057
2058
function hashIt (data ) {
2058
- // The hash
2059
+ // Khai báo hash
2059
2060
let hash = 0 ;
2060
2061
2061
- // Length of string
2062
+ // Lấy chiều dài của chuỗi
2062
2063
const length = data .length ;
2063
2064
2064
- // Loop through every character in data
2065
+ // Lặp qua mỗi kí tự
2065
2066
for (let i = 0 ; i < length; i++ ) {
2066
- // Get character code.
2067
+ // Lấy mã của kí tự
2067
2068
const char = data .charCodeAt (i);
2068
- // Make the hash
2069
+ // Gán giá trị cho hash
2069
2070
hash = ((hash << 5 ) - hash) + char;
2070
- // Convert to 32-bit integer
2071
+ // Chuyển thành định dạng số nguyên 32 bit
2071
2072
hash &= hash;
2072
2073
}
2073
2074
}
2074
2075
```
2075
2076
2076
- ** Good :**
2077
+ ** Tốt :**
2077
2078
``` javascript
2078
2079
2079
2080
function hashIt (data ) {
@@ -2084,36 +2085,38 @@ function hashIt(data) {
2084
2085
const char = data .charCodeAt (i);
2085
2086
hash = ((hash << 5 ) - hash) + char;
2086
2087
2087
- // Convert to 32-bit integer
2088
+ // Chuyển thành định dạng số nguyên 32 bit
2088
2089
hash &= hash;
2089
2090
}
2090
2091
}
2091
2092
2092
2093
```
2093
- ** [ ⬆ back to top ] ( #table-of-contents ) **
2094
+ ** [ ⬆ về đầu trang ] ( #table-of-contents ) **
2094
2095
2095
- ### Don't leave commented out code in your codebase
2096
- Version control exists for a reason. Leave old code in your history.
2096
+ ### Đừng giữ lại những đoạn code bị chú thích trong codebase của bạn.
2097
+ Những công cụ quản lí phiên bản sinh ra để làm nhiệm vụ của chúng.
2098
+ Hãy để code cũ của bạn nằm lại trong dĩ vãng đi.
2097
2099
2098
- ** Bad :**
2100
+ ** Không tốt :**
2099
2101
``` javascript
2100
2102
doStuff ();
2101
2103
// doOtherStuff();
2102
2104
// doSomeMoreStuff();
2103
2105
// doSoMuchStuff();
2104
2106
```
2105
2107
2106
- ** Good :**
2108
+ ** Tốt :**
2107
2109
``` javascript
2108
2110
doStuff ();
2109
2111
```
2110
- ** [ ⬆ back to top ] ( #table-of-contents ) **
2112
+ ** [ ⬆ về đầu trang ] ( #table-of-contents ) **
2111
2113
2112
- ### Don't have journal comments
2113
- Remember, use version control! There's no need for dead code, commented code,
2114
- and especially journal comments. Use ` git log ` to get history!
2114
+ ### Đừng viết các chú thích nhật ký.
2115
+ Hãy nhớ, sử dụng công cụ quản lí phiên bản! Chúng ta không cần những đoạn code
2116
+ vô dụng, bị chú thích và đặc biệt là những chú thích dạng nhật ký...
2117
+ Sử dụng ` git log ` để xem lịch sử được mà!
2115
2118
2116
- ** Bad :**
2119
+ ** Không tốt :**
2117
2120
``` javascript
2118
2121
/**
2119
2122
* 2016-12-20: Removed monads, didn't understand them (RM)
@@ -2126,19 +2129,19 @@ function combine(a, b) {
2126
2129
}
2127
2130
```
2128
2131
2129
- ** Good :**
2132
+ ** Tốt :**
2130
2133
``` javascript
2131
2134
function combine (a , b ) {
2132
2135
return a + b;
2133
2136
}
2134
2137
```
2135
- ** [ ⬆ back to top ] ( #table-of-contents ) **
2138
+ ** [ ⬆ về đầu trang ] ( #table-of-contents ) **
2136
2139
2137
- ### Avoid positional markers
2138
- They usually just add noise. Let the functions and variable names along with the
2139
- proper indentation and formatting give the visual structure to your code.
2140
+ ### Tránh những đánh dấu vị trí
2141
+ Chúng thường xuyên làm nhiễu code. Hãy để những tên hàm, biến cùng với các
2142
+ định dạng thích hợp tự tạo thành cấu trúc trực quan cho code của bạn .
2140
2143
2141
- ** Bad :**
2144
+ ** Không tốt :**
2142
2145
``` javascript
2143
2146
// //////////////////////////////////////////////////////////////////////////////
2144
2147
// Scope Model Instantiation
@@ -2156,7 +2159,7 @@ const actions = function() {
2156
2159
};
2157
2160
```
2158
2161
2159
- ** Good :**
2162
+ ** Tốt :**
2160
2163
``` javascript
2161
2164
$scope .model = {
2162
2165
menu: ' foo' ,
@@ -2167,15 +2170,15 @@ const actions = function() {
2167
2170
// ...
2168
2171
};
2169
2172
```
2170
- ** [ ⬆ back to top ] ( #table-of-contents ) **
2173
+ ** [ ⬆ về đầu trang ] ( #table-of-contents ) **
2171
2174
2172
- ## Translation
2175
+ ## Các ngôn ngữ khác
2173
2176
2174
- This is also available in other languages :
2177
+ Tài liệu này cũng có sẵn ở các ngôn ngữ sau :
2175
2178
2176
2179
- ![ br] ( https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png ) ** Brazilian Portuguese** : [ fesnt/clean-code-javascript] ( https://github.com/fesnt/clean-code-javascript )
2177
2180
- ![ cn] ( https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png ) ** Chinese** : [ alivebao/clean-code-js] ( https://github.com/alivebao/clean-code-js )
2178
2181
- ![ de] ( https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Germany.png ) ** German** : [ marcbruederlin/clean-code-javascript] ( https://github.com/marcbruederlin/clean-code-javascript )
2179
2182
- ![ kr] ( https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png ) ** Korean** : [ qkraudghgh/clean-code-javascript-ko] ( https://github.com/qkraudghgh/clean-code-javascript-ko )
2180
2183
2181
- ** [ ⬆ back to top ] ( #table-of-contents ) **
2184
+ ** [ ⬆ về đầu trang ] ( #table-of-contents ) **
0 commit comments