Skip to content

Commit 7b6f3d6

Browse files
committed
translation
1 parent a08fd69 commit 7b6f3d6

File tree

1 file changed

+22
-39
lines changed

1 file changed

+22
-39
lines changed

README.md

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -781,17 +781,8 @@ function travelToTexas(vehicle) {
781781

782782
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.
783783
È 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!)
795786

796787
**Da evitare**
797788
```javascript
@@ -813,18 +804,15 @@ function combine(val1, val2) {
813804
```
814805
**[⬆ torna su](#lista-dei-contenuti)**
815806

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
819-
resources](https://github.com/petkaantonov/bluebird/wiki/Optimization-killers)
820-
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.
822809

823810
**Da evitare**
824811
```javascript
825812

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
828816
for (let i = 0, len = list.length; i < len; i++) {
829817
// ...
830818
}
@@ -838,10 +826,9 @@ for (let i = 0; i < list.length; i++) {
838826
```
839827
**[⬆ torna su](#lista-dei-contenuti)**
840828

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.
845832

846833
**Da evitare**
847834
```javascript
@@ -870,18 +857,14 @@ inventoryTracker('apples', req, 'www.inventory-awesome.io');
870857
**[⬆ torna su](#lista-dei-contenuti)**
871858

872859
## **Ogetti e strutture dati**
873-
### Use getters and setters
874-
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.
885868

886869

887870
**Da evitare**
@@ -902,17 +885,17 @@ account.balance = 100;
902885
**Bene:**
903886
```javascript
904887
function makeBankAccount() {
905-
// this one is private
888+
// questa proprietà è privata
906889
let balance = 0;
907890

908-
// a "getter", made public via the returned object below
891+
// un "getter", la rende pubblica restituendola in questo modo
909892
function getBalance() {
910893
return balance;
911894
}
912895

913-
// a "setter", made public via the returned object below
896+
// un "setter", la rende pubblica in questo modo
914897
function setBalance(amount) {
915-
// ... validate before updating the balance
898+
// ... e la valida prima di impostarla
916899
balance = amount;
917900
}
918901

0 commit comments

Comments
 (0)