Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3898f8f

Browse files
authored
Avoid conditionals çevirildi
1 parent 813e035 commit 3898f8f

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

README.md

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -719,57 +719,50 @@ if (domYaratildi(node)) {
719719
```
720720
**[⬆ en başa dön](#içindekiler)**
721721

722-
### Avoid conditionals
723-
This seems like an impossible task. Upon first hearing this, most people say,
724-
"how am I supposed to do anything without an `if` statement?" The answer is that
725-
you can use polymorphism to achieve the same task in many cases. The second
726-
question is usually, "well that's great but why would I want to do that?" The
727-
answer is a previous clean code concept we learned: a function should only do
728-
one thing. When you have classes and functions that have `if` statements, you
729-
are telling your user that your function does more than one thing. Remember,
730-
just do one thing.
722+
### Koşullardan Kaçın
723+
Bu imkansız bir iş gibi güzüküyor. Çoğu insan bunu ilk duyduğu ana kadar, " `if` ifadesi olmadan nasıl bir şey yapabilirim? " diyor. Bunun cevabı, birçok durumda aynı işi yapmak için polymorphism kullanabilirsiniz. Genellikle ikinci soru, "iyi güzel ama neden bunu yapmayı isteyeyim ki?" Bunun cevabı ise öğrendiğimiz önceki temiz kod konsepti olan: bir fonksiyon yalnızca bir şey yapmalıdır. `if` ifadesine sahip olan sınıflarınız ve fonksiyonlarınız olduğunda, kullanıcılarınıza fonksiyonunuzun birden fazla şey yaptığını söylüyorsunuz. Hatırla, sadece bir şey yap.
731724

732725
**Kötü:**
733726
```javascript
734-
class Airplane {
727+
class Ucak {
735728
// ...
736-
getCruisingAltitude() {
729+
seyirYuksekliginiGetir() {
737730
switch (this.type) {
738731
case '777':
739-
return this.getMaxAltitude() - this.getPassengerCount();
732+
return this.maxYuksekligiGetir() - this.yolcuSayisiniGetir();
740733
case 'Air Force One':
741-
return this.getMaxAltitude();
734+
return this.maxYuksekligiGetir();
742735
case 'Cessna':
743-
return this.getMaxAltitude() - this.getFuelExpenditure();
736+
return this.maxYuksekligiGetir() - this.yakitHarcamasiniGetir();
744737
}
745738
}
746739
}
747740
```
748741

749742
**İyi:**
750743
```javascript
751-
class Airplane {
744+
class Ucak {
752745
// ...
753746
}
754747

755-
class Boeing777 extends Airplane {
748+
class Boeing777 extends Ucak {
756749
// ...
757-
getCruisingAltitude() {
758-
return this.getMaxAltitude() - this.getPassengerCount();
750+
seyirYuksekliginiGetir() {
751+
return this.maxYuksekligiGetir() - this.yolcuSayisiniGetir();
759752
}
760753
}
761754

762-
class AirForceOne extends Airplane {
755+
class AirForceOne extends Ucak {
763756
// ...
764-
getCruisingAltitude() {
765-
return this.getMaxAltitude();
757+
seyirYuksekliginiGetir() {
758+
return this.maxYuksekligiGetir();
766759
}
767760
}
768761

769-
class Cessna extends Airplane {
762+
class Cessna extends Ucak {
770763
// ...
771-
getCruisingAltitude() {
772-
return this.getMaxAltitude() - this.getFuelExpenditure();
764+
seyirYuksekliginiGetir() {
765+
return this.maxYuksekligiGetir() - this.yakitHarcamasiniGetir();
773766
}
774767
}
775768
```

0 commit comments

Comments
 (0)