10
10
7 . [ Pengujian] ( #pengujian )
11
11
8 . [ Concurrency] ( #concurrency )
12
12
9 . [ Penanganan Kesalahan] ( #penanganan-kesalahan )
13
- 10 . [ Format] ( #format )
13
+ 10 . [ Menyusun Format] ( #menyusun- format )
14
14
11 . [ Komentar] ( #komentar )
15
15
12 . [ Translation] ( #translation )
16
16
@@ -563,7 +563,7 @@ function createTempFile(name) {
563
563
```
564
564
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
565
565
566
- ### Avoid Side Effects (part 1)
566
+ ### Hindari Efek Samping (bagian 1)
567
567
A function produces a side effect if it does anything other than take a value in
568
568
and return another value or values. A side effect could be writing to a file,
569
569
modifying some global variable, or accidentally wiring all your money to a
@@ -608,7 +608,7 @@ console.log(newName); // ['Ryan', 'McDermott'];
608
608
```
609
609
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
610
610
611
- ### Avoid Side Effects (part 2)
611
+ ### Hindari Efek Samping (bagian 2)
612
612
In JavaScript, primitives are passed by value and objects/arrays are passed by
613
613
reference. In the case of objects and arrays, if your function makes a change
614
614
in a shopping cart array, for example, by adding an item to purchase,
@@ -657,7 +657,7 @@ const addItemToCart = (cart, item) => {
657
657
658
658
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
659
659
660
- ### Don't write to global functions
660
+ ### Jangan menulis fungsi global
661
661
Polluting globals is a bad practice in JavaScript because you could clash with another
662
662
library and the user of your API would be none-the-wiser until they get an
663
663
exception in production. Let's think about an example: what if you wanted to
@@ -687,7 +687,7 @@ class SuperArray extends Array {
687
687
```
688
688
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
689
689
690
- ### Favor functional programming over imperative programming
690
+ ### Gunakan functional programming daripada imperative programming
691
691
JavaScript isn't a functional language in the way that Haskell is, but it has
692
692
a functional flavor to it. Functional languages are cleaner and easier to test.
693
693
Favor this style of programming when you can.
@@ -743,7 +743,7 @@ const totalOutput = programmerOutput
743
743
```
744
744
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
745
745
746
- ### Encapsulate conditionals
746
+ ### Enkapsulasi Kondisional
747
747
748
748
** Buruk:**
749
749
``` javascript
@@ -764,7 +764,7 @@ if (shouldShowSpinner(fsmInstance, listNodeInstance)) {
764
764
```
765
765
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
766
766
767
- ### Avoid negative conditionals
767
+ ### Hindari Kondisional Negatif
768
768
769
769
** Buruk:**
770
770
``` javascript
@@ -789,7 +789,7 @@ if (isDOMNodePresent(node)) {
789
789
```
790
790
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
791
791
792
- ### Avoid conditionals
792
+ ### Hindari Kondisional
793
793
This seems like an impossible task. Upon first hearing this, most people say,
794
794
"how am I supposed to do anything without an ` if ` statement?" The answer is that
795
795
you can use polymorphism to achieve the same task in many cases. The second
@@ -845,7 +845,7 @@ class Cessna extends Airplane {
845
845
```
846
846
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
847
847
848
- ### Avoid type-checking (part 1)
848
+ ### Hindari type-checking (bagian 1)
849
849
JavaScript is untyped, which means your functions can take any type of argument.
850
850
Sometimes you are bitten by this freedom and it becomes tempting to do
851
851
type-checking in your functions. There are many ways to avoid having to do this.
@@ -870,7 +870,7 @@ function travelToTexas(vehicle) {
870
870
```
871
871
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
872
872
873
- ### Avoid type-checking (part 2)
873
+ ### Hindari type-checking (bagian 2)
874
874
If you are working with basic primitive values like strings, integers, and arrays,
875
875
and you can't use polymorphism but you still feel the need to type-check,
876
876
you should consider using TypeScript. It is an excellent alternative to normal
@@ -901,7 +901,7 @@ function combine(val1, val2) {
901
901
```
902
902
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
903
903
904
- ### Don't over-optimize
904
+ ### Jangan Optimasi Berlebihan
905
905
Modern browsers do a lot of optimization under-the-hood at runtime. A lot of
906
906
times, if you are optimizing then you are just wasting your time. [ There are good
907
907
resources] ( https://github.com/petkaantonov/bluebird/wiki/Optimization-killers )
@@ -926,7 +926,7 @@ for (let i = 0; i < list.length; i++) {
926
926
```
927
927
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
928
928
929
- ### Remove dead code
929
+ ### Hapus kode mati
930
930
Dead code is just as bad as duplicate code. There's no reason to keep it in
931
931
your codebase. If it's not being called, get rid of it! It will still be safe
932
932
in your version history if you still need it.
@@ -957,8 +957,8 @@ inventoryTracker('apples', req, 'www.inventory-awesome.io');
957
957
```
958
958
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
959
959
960
- ## ** Objects and Data Structures **
961
- ### Use getters and setters
960
+ ## ** Objek dan Struktur Data **
961
+ ### Gunakan getters dan setters
962
962
Using getters and setters to access data on objects could be better than simply
963
963
looking for a property on an object. "Why?" you might ask. Well, here's an
964
964
unorganized list of reasons why:
@@ -1017,7 +1017,7 @@ account.setBalance(100);
1017
1017
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1018
1018
1019
1019
1020
- ### Make objects have private members
1020
+ ### Buat objek memiliki private member
1021
1021
This can be accomplished through closures (for ES5 and below).
1022
1022
1023
1023
** Buruk:**
@@ -1055,8 +1055,8 @@ console.log(`Employee name: ${employee.getName()}`); // Employee name: John Doe
1055
1055
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1056
1056
1057
1057
1058
- ## ** Classes **
1059
- ### Prefer ES2015/ES6 classes over ES5 plain functions
1058
+ ## ** Class **
1059
+ ### Gunakan class ES2015/ES6 daripada fungsi ES5
1060
1060
It's very difficult to get readable class inheritance, construction, and method
1061
1061
definitions for classical ES5 classes. If you need inheritance (and be aware
1062
1062
that you might not), then prefer ES2015/ES6 classes. However, prefer small functions over
@@ -1132,7 +1132,7 @@ class Human extends Mammal {
1132
1132
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1133
1133
1134
1134
1135
- ### Use method chaining
1135
+ ### Gunakan metode chaining
1136
1136
This pattern is very useful in JavaScript and you see it in many libraries such
1137
1137
as jQuery and Lodash. It allows your code to be expressive, and less verbose.
1138
1138
For that reason, I say, use method chaining and take a look at how clean your code
@@ -1214,7 +1214,7 @@ const car = new Car()
1214
1214
```
1215
1215
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1216
1216
1217
- ### Prefer composition over inheritance
1217
+ ### Gunakan composition daripada inheritance
1218
1218
As stated famously in [ * Design Patterns* ] ( https://en.wikipedia.org/wiki/Design_Patterns ) by the Gang of Four,
1219
1219
you should prefer composition over inheritance where you can. There are lots of
1220
1220
good reasons to use inheritance and lots of good reasons to use composition.
@@ -1281,7 +1281,7 @@ class Employee {
1281
1281
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1282
1282
1283
1283
## ** SOLID**
1284
- ### Single Responsibility Principle (SRP)
1284
+ ### Single Responsibility Principle (SRP) / Prinsip Tanggung Jawab Tunggal
1285
1285
As stated in Clean Code, "There should never be more than one reason for a class
1286
1286
to change". It's tempting to jam-pack a class with a lot of functionality, like
1287
1287
when you can only take one suitcase on your flight. The issue with this is
@@ -1338,7 +1338,7 @@ class UserSettings {
1338
1338
```
1339
1339
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1340
1340
1341
- ### Open/Closed Principle (OCP)
1341
+ ### Open/Closed Principle (OCP) / Prinsip Terbuka/Tertutup
1342
1342
As stated by Bertrand Meyer, "software entities (classes, modules, functions,
1343
1343
etc.) should be open for extension, but closed for modification." What does that
1344
1344
mean though? This principle basically states that you should allow users to
@@ -1425,7 +1425,7 @@ class HttpRequester {
1425
1425
```
1426
1426
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1427
1427
1428
- ### Liskov Substitution Principle (LSP)
1428
+ ### Liskov Substitution Principle (LSP) / Prinsip Subtitusi Liskov
1429
1429
This is a scary term for a very simple concept. It's formally defined as "If S
1430
1430
is a subtype of T, then objects of type T may be replaced with objects of type S
1431
1431
(i.e., objects of type S may substitute objects of type T) without altering any
@@ -1540,7 +1540,7 @@ renderLargeShapes(shapes);
1540
1540
```
1541
1541
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1542
1542
1543
- ### Interface Segregation Principle (ISP)
1543
+ ### Interface Segregation Principle (ISP) / Prinsip segregasi antarmuka
1544
1544
JavaScript doesn't have interfaces so this principle doesn't apply as strictly
1545
1545
as others. However, it's important and relevant even with JavaScript's lack of
1546
1546
type system.
@@ -1726,7 +1726,7 @@ Test Driven Development (TDD), that is great, but the main point is to just
1726
1726
make sure you are reaching your coverage goals before launching any feature,
1727
1727
or refactoring an existing one.
1728
1728
1729
- ### Single concept per test
1729
+ ### Satu konsep tiap pengujian
1730
1730
1731
1731
** Buruk:**
1732
1732
``` javascript
@@ -1778,7 +1778,7 @@ describe('MakeMomentJSGreatAgain', () => {
1778
1778
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1779
1779
1780
1780
## ** Concurrency**
1781
- ### Use Promises, not callbacks
1781
+ ### Gunakan Promises, jangan callbacks
1782
1782
Callbacks aren't clean, and they cause excessive amounts of nesting. With ES2015/ES6,
1783
1783
Promises are a built-in global type. Use them!
1784
1784
@@ -1822,7 +1822,7 @@ get('https://en.wikipedia.org/wiki/Robert_Cecil_Martin')
1822
1822
```
1823
1823
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1824
1824
1825
- ### Async/Await are even cleaner than Promises
1825
+ ### Async/Await lebih sederhana daripada Promises
1826
1826
Promises are a very clean alternative to callbacks, but ES2017/ES8 brings async and await
1827
1827
which offer an even cleaner solution. All you need is a function that is prefixed
1828
1828
in an ` async ` keyword, and then you can write your logic imperatively without
@@ -1865,13 +1865,13 @@ async function getCleanCodeArticle() {
1865
1865
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1866
1866
1867
1867
1868
- ## ** Error Handling **
1868
+ ## ** Penanganan Kesalahan **
1869
1869
Thrown errors are a good thing! They mean the runtime has successfully
1870
1870
identified when something in your program has gone wrong and it's letting
1871
1871
you know by stopping function execution on the current stack, killing the
1872
1872
process (in Node), and notifying you in the console with a stack trace.
1873
1873
1874
- ### Don't ignore caught errors
1874
+ ### Jangan abaikan kesalahan yg tertangkap
1875
1875
Doing nothing with a caught error doesn't give you the ability to ever fix
1876
1876
or react to said error. Logging the error to the console (` console.log ` )
1877
1877
isn't much better as often times it can get lost in a sea of things printed
@@ -1903,7 +1903,7 @@ try {
1903
1903
}
1904
1904
```
1905
1905
1906
- ### Don't ignore rejected promises
1906
+ ### Jangan abaikan promise yg ditolak
1907
1907
For the same reason you shouldn't ignore caught errors
1908
1908
from ` try/catch ` .
1909
1909
@@ -1938,7 +1938,7 @@ getdata()
1938
1938
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1939
1939
1940
1940
1941
- ## ** Formatting **
1941
+ ## ** Menyusun Format **
1942
1942
Formatting is subjective. Like many rules herein, there is no hard and fast
1943
1943
rule that you must follow. The main point is DO NOT ARGUE over formatting.
1944
1944
There are [ tons of tools] ( http://standardjs.com/rules.html ) to automate this.
@@ -1948,7 +1948,7 @@ For things that don't fall under the purview of automatic formatting
1948
1948
(indentation, tabs vs. spaces, double vs. single quotes, etc.) look here
1949
1949
for some guidance.
1950
1950
1951
- ### Use consistent capitalization
1951
+ ### Gunakan Kapitalisasi yg konsisten
1952
1952
JavaScript is untyped, so capitalization tells you a lot about your variables,
1953
1953
functions, etc. These rules are subjective, so your team can choose whatever
1954
1954
they want. The point is, no matter what you all choose, just be consistent.
@@ -1985,7 +1985,7 @@ class Alpaca {}
1985
1985
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
1986
1986
1987
1987
1988
- ### Function callers and callees should be close
1988
+ ### Fungsi yg memanggil dan yang dipanggil seharusnya berdekatan
1989
1989
If a function calls another, keep those functions vertically close in the source
1990
1990
file. Ideally, keep the caller right above the callee. We tend to read code from
1991
1991
top-to-bottom, like a newspaper. Because of this, make your code read that way.
@@ -2070,8 +2070,8 @@ review.perfReview();
2070
2070
2071
2071
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
2072
2072
2073
- ## ** Comments **
2074
- ### Only comment things that have business logic complexity .
2073
+ ## ** Komentar **
2074
+ ### Komentar hanya untuk hal-hal yang memiliki kompleksitas logika .
2075
2075
Comments are an apology, not a requirement. Good code * mostly* documents itself.
2076
2076
2077
2077
** Buruk:**
@@ -2114,7 +2114,7 @@ function hashIt(data) {
2114
2114
```
2115
2115
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
2116
2116
2117
- ### Don't leave commented out code in your codebase
2117
+ ### Jangan meninggalkan kode yang dikomentari dalam basis kode anda
2118
2118
Version control exists for a reason. Leave old code in your history.
2119
2119
2120
2120
** Buruk:**
@@ -2131,7 +2131,7 @@ doStuff();
2131
2131
```
2132
2132
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
2133
2133
2134
- ### Don't have journal comments
2134
+ ### Jangan ada komentar tentang jurnal
2135
2135
Remember, use version control! There's no need for dead code, commented code,
2136
2136
and especially journal comments. Use ` git log ` to get history!
2137
2137
@@ -2156,7 +2156,7 @@ function combine(a, b) {
2156
2156
```
2157
2157
** [ ⬆ Kembali ke atas] ( #daftar-isi ) **
2158
2158
2159
- ### Avoid positional markers
2159
+ ### Hindari komentar marker
2160
2160
They usually just add noise. Let the functions and variable names along with the
2161
2161
proper indentation and formatting give the visual structure to your code.
2162
2162
0 commit comments