Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
clean-code-javascript-tr
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Ömer SAVAŞ
clean-code-javascript-tr
Commits
fbf71eca
Unverified
Kaydet (Commit)
fbf71eca
authored
Ock 18, 2019
tarafından
Mert Can Bilgiç
Kaydeden (comit)
GitHub
Ock 18, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update README.md
Nesneler ve veri yapıları çevrildi
üst
6cd08cb2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
48 deletions
+47
-48
README.md
README.md
+47
-48
No files found.
README.md
Dosyayı görüntüle @
fbf71eca
...
@@ -901,105 +901,104 @@ inventoryTracker('apples', req, 'www.inventory-awesome.io');
...
@@ -901,105 +901,104 @@ inventoryTracker('apples', req, 'www.inventory-awesome.io');
```
```
**[⬆ en başa dön](#içindekiler)**
**[⬆ en başa dön](#içindekiler)**
## **
Objects and Data Structures
**
## **
Nesneler ve Veri Yapıları
**
###
Use getters and setters
###
Setter ve Getter kullanın
Using getters and setters to access data on objects could be better than simply
Nesnelerdeki verilere erişmek için Setter ve Getter kullanmak sadece bir nesnedeki
looking for a property on an object. "Why?" you might ask. Well, here's an
özellikleri aramaktan daha iyi olabilir. "Neden?" diye soracaksınız. Peki, işte burada
unorganized list of reasons why
:
sebeplerinin bir listesi var
:
*
When you want to do more beyond getting an object property, you don't have
*
Bir nesne özelliğini elde etmekten daha fazla şey yapmak istediğinizde kod tabanınızdaki
to look up and change every accessor in your codebase.
her erişimciyi aramanız ve değiştirmeniz gerekmez.
*
Makes adding validation simple when doing a
`set`
.
*
`set`
işlemi yaparken doğrulama eklemeyi kolaylaştırır.
*
Encapsulates the internal representation.
*
İç temsili kapsüller.
*
Easy to add logging and error handling when getting and setting.
*
Set ve Get işlemlerini gerçekleştirirken kayıt tutmayı (log) ve hata yakalamayı eklemek kolaydır.
*
You can lazy load your object's properties, let's say getting it from a
*
Mesela nesnenizin özelliklerini sunucudan alırken Lazy Load kullanabilirsiniz.
server.
**Kötü:**
**Kötü:**
```
javascript
```
javascript
function
makeBankAccount
()
{
function
bankaHesabiOlustur
()
{
// ...
// ...
return
{
return
{
ba
lanc
e
:
0
,
ba
kiy
e
:
0
,
// ...
// ...
};
};
}
}
const
account
=
makeBankAccount
();
const
hesap
=
bankaHesabiOlustur
();
account
.
balanc
e
=
100
;
hesap
.
bakiy
e
=
100
;
```
```
**İyi:**
**İyi:**
```
javascript
```
javascript
function
makeBankAccount
()
{
function
bankaHesabiOlustur
()
{
//
this one is
private
//
bu
private
let
ba
lanc
e
=
0
;
let
ba
kiy
e
=
0
;
//
a "getter", made public via the returned object below
//
Getter aşağıda döndürülen nesne aracılığıyla public hale getirildi
function
getBa
lanc
e
()
{
function
getBa
kiy
e
()
{
return
ba
lanc
e
;
return
ba
kiy
e
;
}
}
//
a "setter", made public via the returned object below
//
Setter aşağıda döndürülen nesne aracılığıyla public hale getirildi
function
setBa
lance
(
amount
)
{
function
setBa
kiye
(
deger
)
{
// ...
validate before updating the balance
// ...
bakiyeyi güncellemeden önce onaylar
ba
lance
=
amount
;
ba
kiye
=
deger
;
}
}
return
{
return
{
// ...
// ...
getBa
lanc
e
,
getBa
kiy
e
,
setBa
lanc
e
,
setBa
kiy
e
,
};
};
}
}
const
account
=
makeBankAccount
();
const
hesap
=
bankaHesabiOlustur
();
account
.
setBalanc
e
(
100
);
hesap
.
setBakiy
e
(
100
);
```
```
**[⬆ en başa dön](#içindekiler)**
**[⬆ en başa dön](#içindekiler)**
###
Make objects have private members
###
Nesnelerin private üyelere sahip olmasını sağlayın.
This can be accomplished through closures (for ES5 and below
).
Bu, kapamalarla(closures) gerçekleştirilebilir. (ES5 ve altı için
).
**Kötü:**
**Kötü:**
```
javascript
```
javascript
const
Employee
=
function
(
name
)
{
const
Calisan
=
function
(
isim
)
{
this
.
name
=
name
;
this
.
isim
=
isim
;
};
};
Employee
.
prototype
.
getName
=
function
getName
()
{
Calisan
.
prototype
.
getIsim
=
function
getIsim
()
{
return
this
.
name
;
return
this
.
isim
;
};
};
const
employee
=
new
Employee
(
'John Doe'
);
const
calisan
=
new
calisan
(
'John Doe'
);
console
.
log
(
`
Employee name:
${
employee
.
getName
()}
`
);
// Employee name
: John Doe
console
.
log
(
`
Calisanin ismi:
${
calisan
.
getIsim
()}
`
);
// Calisanin ismi
: John Doe
delete
employee
.
name
;
delete
calisan
.
isim
;
console
.
log
(
`
Employee name:
${
employee
.
getName
()}
`
);
// Employee name
: undefined
console
.
log
(
`
Calisanin ismi:
${
calisan
.
getIsim
()}
`
);
// Calisanin ismi
: undefined
```
```
**İyi:**
**İyi:**
```
javascript
```
javascript
function
makeEmployee
(
name
)
{
function
calisanOlustur
(
isim
)
{
return
{
return
{
get
Name
()
{
get
Isim
()
{
return
name
;
return
isim
;
},
},
};
};
}
}
const
employee
=
makeEmployee
(
'John Doe'
);
const
calisan
=
calisanOlustur
(
'John Doe'
);
console
.
log
(
`
Employee name:
${
employee
.
getName
()}
`
);
// Employee name
: John Doe
console
.
log
(
`
Calisanin ismi:
${
calisan
.
getIsim
()}
`
);
// Calisanin ismi
: John Doe
delete
employee
.
name
;
delete
calisan
.
isim
;
console
.
log
(
`
Employee name:
${
employee
.
getName
()}
`
);
// Employee name
: John Doe
console
.
log
(
`
Calisanin ismi:
${
calisan
.
getIsim
()}
`
);
// Calisanin ismi
: John Doe
```
```
**[⬆ en başa dön](#içindekiler)**
**[⬆ en başa dön](#içindekiler)**
## **
Classes
**
## **
Sınıflar
**
### Prefer ES2015/ES6 classes over ES5 plain functions
### Prefer ES2015/ES6 classes over ES5 plain functions
It's very difficult to get readable class inheritance, construction, and method
It's very difficult to get readable class inheritance, construction, and method
definitions for classical ES5 classes. If you need inheritance (and be aware
definitions for classical ES5 classes. If you need inheritance (and be aware
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment