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: README.md
+22-39Lines changed: 22 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -781,17 +781,8 @@ function travelToTexas(vehicle) {
781
781
782
782
Se stai lavorando con tipi di dati primitivi come stringhe o interi e non puoi utilizzare il paradigma del polimorfismo, ma senti ancora l'esigenza di validare il tipo di dato considera l'utilizzo di TypeScript.
783
783
È una vlidissima alternativa al normale JavaScript che fornicsce una validazione di tipi statica utilizzando la sintassi JavaScript.
784
-
785
-
786
-
If you are working with basic primitive values like strings and integers,
787
-
and you can't use polymorphism but you still feel the need to type-check,
788
-
you should consider using TypeScript. It is an excellent alternative to normal
789
-
JavaScript, as it provides you with static typing on top of standard JavaScript
790
-
syntax. The problem with manually type-checking normal JavaScript is that
791
-
doing it well requires so much extra verbiage that the faux "type-safety" you get
792
-
doesn't make up for the lost readability. Keep your JavaScript clean, write
793
-
good tests, and have good code reviews. Otherwise, do all of that but with
794
-
TypeScript (which, like I said, is a great alternative!).
784
+
Il problema con la validazione manuale dei tipi utilizzando JavaScript standard è che richiede tanto codice extra che non compensa la scarsa leggibilità del codice ottenuto.
785
+
Mantieni pulito il tuo codice, scrivi dei test validi e cerca di fare delle buone revisioni del coidice. Altrimenti utilizza TypeScript (che come detto in precedenza è una validissima alternativa!)
795
786
796
787
**Da evitare**
797
788
```javascript
@@ -813,18 +804,15 @@ function combine(val1, val2) {
813
804
```
814
805
**[⬆ torna su](#lista-dei-contenuti)**
815
806
816
-
### Don't over-optimize
817
-
Modern browsers do a lot of optimization under-the-hood at runtime. A lot of
818
-
times, if you are optimizing then you are just wasting your time. [There are good
for seeing where optimization is lacking. Target those in the meantime, until
821
-
they are fixed if they can be.
807
+
### Non ottimizzare eccessivamente
808
+
I browser moderni eseguono un sacco di ottimizzazione "sottobanco". Molte volte, quando cerchi di ottimizzare il tuo codice, stai perdendo tempo prezioso. [Ci sono tante guide](https://github.com/petkaantonov/bluebird/wiki/Optimization-killers) che aiutano a capire quali tipi di ottimizzazione sono superflui e quali no. Utilizza queste guide nel frattempo, fintanto che queste mancanze non verranno colmate.
822
809
823
810
**Da evitare**
824
811
```javascript
825
812
826
-
// On old browsers, each iteration with uncached `list.length` would be costly
827
-
// because of `list.length` recomputation. In modern browsers, this is optimized.
813
+
// Nei vecchi browser ogni volta che in un ciclo verifichi `list.length` potrebbe
814
+
// essere dispendioso per via del ricalcolo della lunghezza. Nei browser moderni
815
+
// questa operazione è stata ottimizzata
828
816
for (let i =0, len =list.length; i < len; i++) {
829
817
// ...
830
818
}
@@ -838,10 +826,9 @@ for (let i = 0; i < list.length; i++) {
838
826
```
839
827
**[⬆ torna su](#lista-dei-contenuti)**
840
828
841
-
### Remove dead code
842
-
Dead code is just as Male as duplicate code. There's no reason to keep it in
843
-
your codebase. If it's not being called, get rid of it! It will still be safe
844
-
in your version history if you still need it.
829
+
### Rimuovi il codice inutilizzato
830
+
Il codice inutilizzato è dannoso quanto il codice duplicato. Non c'è motivo per cui tenerlo nella tua codebase. Se realmente non viene utilizzato rimuovilo!
831
+
Sarà comunque presente nella storia del tuo file se utilizzi un sistema di versioning nel caso in cui dovesse servirti.
Using getters and setters to access data on objects could be better than simply
875
-
looking for a property on an object. "Why?" you might ask. Well, here's an
876
-
unorganized list of reasons why:
877
-
878
-
* When you want to do more beyond getting an object property, you don't have
879
-
to look up and change every accessor in your codebase.
880
-
* Makes adding validation simple when doing a `set`.
881
-
* Encapsulates the internal representation.
882
-
* Easy to add logging and error handling when getting and setting.
883
-
* You can lazy load your object's properties, let's say getting it from a
884
-
server.
860
+
### Utilizza getter e setter
861
+
Utilizzare getter e setter per acceedere ai dati di un oggetto può essere meglio che accedere direttamente alle sue proprietà. Ti starai chiedendo il motivo.
862
+
Eccoti qualche motivo per cui utilizzare getter e setter:
863
+
* Quando hai bisogno di eseguire un'operazione col dato recuperato, non devi andare a modificarlo ogni volta che accedi al dato nel tuo codice.
864
+
* Valida il dato nel momento in cui lo setti con `set`
865
+
* Incapsula la rappresentazione interna
866
+
* È più facile loggare e gestire gli errori quando imposti o recuperi un dato
867
+
* Puoi caricare i dati del tuo oggetto in modalità *lazy*, per esempio caricandoli dal server.
885
868
886
869
887
870
**Da evitare**
@@ -902,17 +885,17 @@ account.balance = 100;
902
885
**Bene:**
903
886
```javascript
904
887
functionmakeBankAccount() {
905
-
//this one is private
888
+
//questa proprietà è privata
906
889
let balance =0;
907
890
908
-
//a "getter", made public via the returned object below
891
+
//un "getter", la rende pubblica restituendola in questo modo
909
892
functiongetBalance() {
910
893
return balance;
911
894
}
912
895
913
-
//a "setter", made public via the returned object below
0 commit comments