You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/03-code-quality/03-comments/article.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,64 +117,64 @@ Relitanya, kita tak bisa menghindar total dari komentar "penjelasan". Ada algori
117
117
118
118
## Komentar baik
119
119
120
-
Jadi, explanatory comments are usually bad. Which comments are good?
120
+
Jadi, komentar penjelasan biasanya jelek. Komentar mana yang bagus?
121
121
122
-
Describe the architecture
123
-
: Provide a high-level overview of components, how they interact, what's the control flow in various situations... In short -- the bird's eye view of the code. There's a special language [UML](http://wikipedia.org/wiki/Unified_Modeling_Language)to build high-level architecture diagrams explaining the code. Definitely worth studying.
122
+
Jelaskan arsitekturnya
123
+
: Sediakan overview tingkat-tinggi dari komponen, bagaimana mereka berinteraksi, apa aliran kontrolnya di berbagai situasi... Singkatnya -- gambaran umum dari kode. Ada bahasa spesial [UML](http://wikipedia.org/wiki/Unified_Modeling_Language)untuk membangun diagram arsitektur tingkat-tinggi yang menjelaskan kode. Sangat berfaedah untuk dipelajari.
124
124
125
-
Document function parameters and usage
126
-
: There's a special syntax [JSDoc](http://en.wikipedia.org/wiki/JSDoc)to document a function: usage, parameters, returned value.
125
+
Parameter dan kegunaan fungsi dokumen
126
+
: Ada syntax spesial [JSDoc](http://en.wikipedia.org/wiki/JSDoc)untuk mendokumentasi fungsi: kegunaan, parameter, nilai kembalian.
127
127
128
-
For instance:
128
+
Misalnya:
129
129
```js
130
130
/**
131
-
* Returns x raised to the n-th power.
131
+
* Kembalikan x yang diberi pangkat n.
132
132
*
133
-
* @param {number} x The number to raise.
134
-
* @param {number} n The power, must be a natural number.
135
-
* @return {number} x raised to the n-th power.
133
+
* @param {number} x Angka yang mau dinaikkan.
134
+
* @param {number} n Pangkat, harus angka asli.
135
+
* @return {number} x hasil setelah pangkat n.
136
136
*/
137
137
function pow(x, n) {
138
138
...
139
139
}
140
140
```
141
141
142
-
Such comments allow us to understand the purpose of the function and use it the right way without looking in its code.
142
+
Komentar macam ini membolehkan kita memahami maksud fungsi dan memakainya dengan tepat tanpa melihat isi kode.
143
143
144
-
By the way, many editors like [WebStorm](https://www.jetbrains.com/webstorm/) can understand them as well and use them to provide autocomplete and some automatic code-checking.
144
+
Oya, banyak editor seperti [WebStorm](https://www.jetbrains.com/webstorm/) bisa memahami mereka juga dan memakai mereka untuk menyediakan autocomplete dan beberapa pengecekan-kode otomatis.
145
145
146
-
Also, there are tools like [JSDoc 3](https://github.com/jsdoc3/jsdoc) that can generate HTML-documentation from the comments. You can read more information about JSDoc at <http://usejsdoc.org/>.
146
+
Juga, Ada tool seperti [JSDoc 3](https://github.com/jsdoc3/jsdoc) yang bisa menggenerate dokumentasi-HTML dari komentar. Kamu bisa baca informasi lebih tentang JSDoc di <http://usejsdoc.org/>.
147
147
148
-
Why is the task solved this way?
149
-
: What's written is important. But what's *not* written may be even more important to understand what's going on. Why is the task solved exactly this way? The code gives no answer.
148
+
Kenapa tugas ini diselesaikan begini?
149
+
: Apa yang tertulis itu penting. Tapi apa yang *tak* tertilis mungkin lebih penting lagi untuk memahami yang terjadi. Kenapa tugas ini diselesaikan tepat seperti ini? Kodenya tak memberikan jawaban.
150
150
151
-
If there are many ways to solve the task, why this one? Especially when it's not the most obvious one.
151
+
Jika ada banyak cara menyelesaikan tugas, kenapa harus ini? Apalagi ini belum jelas.
152
152
153
-
Without such comments the following situation is possible:
154
-
1. You (or your colleague) open the code written some time ago, and see that it's "suboptimal".
155
-
2. You think: "How stupid I was then, and how much smarter I'm now", and rewrite using the "more obvious and correct" variant.
156
-
3. ...The urge to rewrite was good. But in the process you see that the "more obvious" solution is actually lacking. You even dimly remember why, because you already tried it long ago. You revert to the correct variant, but the time was wasted.
153
+
Tanpa komentar macam ini situasi berikut memungkinkan:
154
+
1. Kamu (atau kolegamu) membuka kode yang ditulis kapan hari, dan melihat bahwa ini "suboptimal".
155
+
2. Kamu berpikir: "Koq bego ya saya waktu itu, dan lihat betapa pintar saya sekarang", dan menulis-ulang menggunakan varian yang "lebih jelas dan benar".
156
+
3. ...Urgensi menulis-ulang itu bagus. Tapi di proses yang kamu lihat adalah solusi "lebih jelas" tersebut jadi minus. Kamu bahkan agak lupa kenapa, karena kamu sudah mencobanya di masa lalu. Kamu balikkan ke varian yang benar, tapi waktumu terbuang percuma.
157
157
158
-
Comments that explain the solution are very important. They help to continue development the right way.
158
+
Komentar yang menjelaskan solusi itu penting. Mereka membantu melanjutkan pengembangan ke arah yang benar.
159
159
160
-
Any subtle features of the code? Where they are used?
161
-
: If the code has anything subtle and counter-intuitive, it's definitely worth commenting.
160
+
Ada fitur halus dari kodenya? Di mana mereka dipakai?
161
+
: Jika kodenya punya sesuatu yang halus dan kontra-intuitif, itu sudah pasti bagus untuk dikomentari.
162
162
163
163
## Kesimpulan
164
164
165
-
An important sign of a good developer is comments: their presence and even their absence.
165
+
Tanpa penting dari pengembang yang baik ialah komentar: kehadiran mereka dan kealfaan mereka.
166
166
167
-
Good comments allow us to maintain the code well, come back to it after a delay and use it more effectively.
167
+
Komentar yang baik membuat kita memelihara kode lebih baik, kembali ke situ setelah delay dan memakainya secara efektif.
168
168
169
-
**Comment this:**
169
+
**Komentari ini:**
170
170
171
-
-Overall architecture, high-level view.
172
-
-Function usage.
173
-
-Important solutions, especially when not immediately obvious.
0 commit comments