Skip to content

Commit bc3c1a7

Browse files
authored
Merge pull request hienvd#5 from hienvd/feature/10-comments
Translate 10.Comments
2 parents 0d24cf6 + 9342b3c commit bc3c1a7

File tree

1 file changed

+39
-36
lines changed

1 file changed

+39
-36
lines changed

README.md

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Original Repository: [ryanmcdermott/clean-code-javascript](https://github.com/ry
22

33
# clean-code-javascript
44

5-
## Table of Contents
5+
## Mục lục
66
1. [Introduction](#introduction)
77
2. [Biến](#biến)
88
3. [Functions](#functions)
@@ -12,8 +12,8 @@ Original Repository: [ryanmcdermott/clean-code-javascript](https://github.com/ry
1212
7. [Concurrency](#concurrency)
1313
8. [Error Handling](#error-handling)
1414
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)
1717

1818
## Introduction
1919
![Humorous image of software quality estimation as a count of how many expletives
@@ -2048,32 +2048,33 @@ review.perfReview();
20482048

20492049
**[⬆ back to top](#table-of-contents)**
20502050

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.
20542055

2055-
**Bad:**
2056+
**Không tốt:**
20562057
```javascript
20572058
function hashIt(data) {
2058-
// The hash
2059+
// Khai báo hash
20592060
let hash = 0;
20602061

2061-
// Length of string
2062+
// Lấy chiều dài của chuỗi
20622063
const length = data.length;
20632064

2064-
// Loop through every character in data
2065+
// Lặp qua mỗi kí tự
20652066
for (let i = 0; i < length; i++) {
2066-
// Get character code.
2067+
// Lấy mã của kí tự
20672068
const char = data.charCodeAt(i);
2068-
// Make the hash
2069+
// Gán giá trị cho hash
20692070
hash = ((hash << 5) - hash) + char;
2070-
// Convert to 32-bit integer
2071+
// Chuyển thành định dạng số nguyên 32 bit
20712072
hash &= hash;
20722073
}
20732074
}
20742075
```
20752076

2076-
**Good:**
2077+
**Tốt:**
20772078
```javascript
20782079

20792080
function hashIt(data) {
@@ -2084,36 +2085,38 @@ function hashIt(data) {
20842085
const char = data.charCodeAt(i);
20852086
hash = ((hash << 5) - hash) + char;
20862087

2087-
// Convert to 32-bit integer
2088+
// Chuyển thành định dạng số nguyên 32 bit
20882089
hash &= hash;
20892090
}
20902091
}
20912092

20922093
```
2093-
**[back to top](#table-of-contents)**
2094+
**[về đầu trang](#table-of-contents)**
20942095

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.
20972099

2098-
**Bad:**
2100+
**Không tốt:**
20992101
```javascript
21002102
doStuff();
21012103
// doOtherStuff();
21022104
// doSomeMoreStuff();
21032105
// doSoMuchStuff();
21042106
```
21052107

2106-
**Good:**
2108+
**Tốt:**
21072109
```javascript
21082110
doStuff();
21092111
```
2110-
**[back to top](#table-of-contents)**
2112+
**[về đầu trang](#table-of-contents)**
21112113

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à!
21152118

2116-
**Bad:**
2119+
**Không tốt:**
21172120
```javascript
21182121
/**
21192122
* 2016-12-20: Removed monads, didn't understand them (RM)
@@ -2126,19 +2129,19 @@ function combine(a, b) {
21262129
}
21272130
```
21282131

2129-
**Good:**
2132+
**Tốt:**
21302133
```javascript
21312134
function combine(a, b) {
21322135
return a + b;
21332136
}
21342137
```
2135-
**[back to top](#table-of-contents)**
2138+
**[về đầu trang](#table-of-contents)**
21362139

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.
21402143

2141-
**Bad:**
2144+
**Không tốt:**
21422145
```javascript
21432146
////////////////////////////////////////////////////////////////////////////////
21442147
// Scope Model Instantiation
@@ -2156,7 +2159,7 @@ const actions = function() {
21562159
};
21572160
```
21582161

2159-
**Good:**
2162+
**Tốt:**
21602163
```javascript
21612164
$scope.model = {
21622165
menu: 'foo',
@@ -2167,15 +2170,15 @@ const actions = function() {
21672170
// ...
21682171
};
21692172
```
2170-
**[back to top](#table-of-contents)**
2173+
**[về đầu trang](#table-of-contents)**
21712174

2172-
## Translation
2175+
## Các ngôn ngữ khác
21732176

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:
21752178

21762179
- ![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)
21772180
- ![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)
21782181
- ![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)
21792182
- ![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)
21802183

2181-
**[back to top](#table-of-contents)**
2184+
**[về đầu trang](#table-of-contents)**

0 commit comments

Comments
 (0)