Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Italian translation #1

Open
wants to merge 14 commits into
base: trunk
Choose a base branch
from
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ These are some example scores, achieved using IntelliJ.
<tr><td> 9 </td><td> xx </td><td></td></tr>
</table>

## Alternative version
## Alternative versions
There's an alternative version that was implemented using TDD from scratch in the
`reimplemented-with-tdd` branch of the repository.

There's also an Italian version in the `italian` branch.

## Acknowledgements
This exercise was mainly taken from an example by Lance Walton.

Expand All @@ -80,4 +82,4 @@ These instructions were mostly stolen from @jasongorman's

- we used `double` for the calculations. Using floating point types is usually a bad idea for money,
but here it's to simplify the exercises. The alternative TDD version uses `long`. Both should probably
use a decimal format.
use a decimal format.
98 changes: 98 additions & 0 deletions README_IT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Refactoring Golf

_Refactoring Golf_ è un gioco concepito per essere l'equivalemte dello stretching
per i 'muscoli' della rifattorizzazione, nonchè per spingervi a scoprire quello che
il vostro IDE può fare con scorciatoie e automatismi. L'idea è quella di concentrarsi
su un aspetto specifico del processo di codifica e capire fin dove ci si può spingere.

Questo repo contiene svariate versioni di una classe che ha come scopo quello di calcolare
le tasse (IRPEF) di una busta paga.

* I primi 5'000€ sono esentasse
* Lo scaglione sino a 20'000€ è tassato al 10%
* Lo scaglione sino a 40'000€ è tassato al 20%
* Oltre i 40'000€ le tesse sono al 40%

(I valori indicati sono di fantasia - non fanno riferimento ad alcun aspetto legale)-

Ogni versione è una rifattorizzazione delle versione precedente. Applicando la metafora del gioco
del golf, ogni versione è chiamata "buca".

L'obiettivo è di rifattorizzare ogni _buca_ nella versione successiva nel modo più sicuro
ed efficiente, utilizzando le potenzialità dell'IDE con il minor numero di "colpi" possibili.
Un _colpo_ è definito come una azione che modifica il codice; ogni colpo costa punti.

Il vostro compagno dovrà annotare con cura il vostro punteggio nel modo seguente:

- 0 punti per formattazione e selezione
- 1 punto for ogni mdofica effettuata utilizzando una scorciatoia o una caratteristica dell'IDE
(esempio: refactoring automatica, template di codice, rename, Find/replace).
- 2 punti per ogni modifica manuale. Notare che una singola modifica può comprendere più linee di codice.
- Nel caso che la modifica porti a un codice che fa fallire i test, la penalità è _raddoppiata_

Avete a disposizione 2 tentativi per ogni round per determinare il punteggio migliore.

## Suggerimenti
- Ogni versione possiede un file chiamato `istruzioni.md` che desrive le motivazioni alla base del prossimo refactoring.
- Potrebbe essere una buona idea tenere aperto il codice su un'altra finestra, o anche sul computer del partner.
È facile perdersi quando si lavora su più file.
- Committate il codice frequentemente, specialmente dopo ogni stadio di refactoring. Ciò faciliterà un eventuale
rollback nel caso vogliate fare un secondo tentativo o vi perdiate.
- Lanciate i test dopo ogni "colpo" - per farlo basta selezionare la cartella superiore di *refactoring-golf* in
nella vista progetto e selezionare `Run 'All Tests'` dal menu pop-up.
- Controllate spesso il vostro codice in modo che sia facile tentare un refactoring più di una volta. Idea ha anche
un'ottima so it's easier to try a refactoring more than once. Idea ha anche una opzione (_Local History_) che può risultare utile.

## Pratica (IDE)
- L'esercizio è stato scritto con _Intellj Idea_. Dovreste riuscire facilmente a clonare il repo e aprirlo
(_Open_) come progetto.
- Idea ha una _Keymap Reference_ disponibile dal menu di aiuto. Se non lo conoscete, vale la
pena leggerlo e tenerlo a portata di mano.
- Per iniziare va benissimo usare il mouse, ma cercate di imparare le scorciatoie di tastiera.
- Non dovrebbero esserci problemi di sorta usando altri IDE (Eclipse, VS, VSC, Netbeans), ma l'importazione va fatta
manualmente e potrebbero essere necessari aggiustamenti

#Pratica (Repl)
- L'esercizio è stato adattato per essere usato online tramite Repl.it. Importate questo repo in Repl.it e tutto
dovrebbe funzionare.
- Lanciando il main si lanciano i test della buca 1. Per cambiare buca basta modificare il parametro
passato a TestRunnen, nel medoto Main.

## Esempio di punteggi
Ecco qualche esempio di punteggio, ottenuto tramite IntelliJ.

<table border="1">
<tr><th>Buca</th><th>Punteggio migliore</th><th>Note</th></tr>
<tr><td> 1 </td><td> 6 </td><td></td></tr>
<tr><td> 2 </td><td> 3 </td><td></td></tr>
<tr><td> 3 </td><td> 9 </td><td></td></tr>
<tr><td> 4 </td><td> 17 </td><td>molti editing manuali</td></tr>
<tr><td> 5 </td><td> 13 </td><td></td></tr>
<tr><td> 6 </td><td> 14 </td><td></td></tr>
<tr><td> 7 </td><td> 29 </td><td>Piuttosto difficile, ma fattibile</td></tr>
<tr><td> 8 </td><td> 8 </td><td></td></tr>
<tr><td> 9 </td><td> xx </td><td></td></tr>
</table>

## Versioni alternative
La versione in inglese è presente nel branch `main`.

Troverete anche una versione alternativa implementata da zero con TFF nel branch
`reimplemented-with-tdd` del repo

## Crediti
Gran parte di questo esercizio è stato preso da Lance Walton.

Altre idee sono prese da David Denton e Ivan Sanchez, ispirati da @ivanmoore e @rchatley

Le istruzioni sono state per lo più rubate da @jasongorman:
<a href="https://github.com/jasongorman/RefactoringGolfJava">Refactoring Golf</a>.


## Notes

- Usiamo`double` per i calcoli. Usare i floating point è in genere una pessima idea per memorizzare il denaro; qui
lo abbiamo fatto per semplificare l'esercizio. La versione alternativa con TDD usa i `long`.
In entrambi i casi si dovrebbero usare i formati decimali.

- questa traduzione è stata fatta da @piffy
10 changes: 10 additions & 0 deletions refactoring-golf.iml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,15 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$USER_HOME$/.m2/repository/junit/junit/4.12/junit-4.12.jar!/" />
<root url="jar://$USER_HOME$/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
8 changes: 8 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public class Main {


public static void main(String[] args) {
TestRunner tr = new TestRunner();
tr.main(1);
}
}
56 changes: 56 additions & 0 deletions src/TestRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import bustapaga.buca01.BustaPagaTest01;
import bustapaga.buca02.BustaPagaTest02;
import bustapaga.buca03.BustaPagaTest03;
import bustapaga.buca04.BustaPagaTest04;
import bustapaga.buca05.BustaPagaTest05;
import bustapaga.buca06.BustaPagaTest06;
import bustapaga.buca07.BustaPagaTest07;
import bustapaga.buca08.BustaPagaTest08;
import bustapaga.buca09.BustaPagaTaxTest09;
import bustapaga.buca09.BustaPagaTest09;
import bustapaga.buca09.CalcolatoreScaglioneTasseTest;
import bustapaga.buca10.BustaPagaTaxTest10;
import bustapaga.buca10.BustaPagaTest10;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class TestRunner {
public static void main(int buca) {
int count=0,count2=0,count3=0;
Result result=null, result2=null,result3=null;
switch (buca) {
case 1 : result = JUnitCore.runClasses(BustaPagaTest01.class); break;
case 2 : result = JUnitCore.runClasses(BustaPagaTest02.class); break;
case 3 : result = JUnitCore.runClasses(BustaPagaTest03.class); break;
case 4 : result = JUnitCore.runClasses(BustaPagaTest04.class); break;
case 5 : result = JUnitCore.runClasses(BustaPagaTest05.class); break;
case 6 : result = JUnitCore.runClasses(BustaPagaTest06.class); break;
case 7 : result = JUnitCore.runClasses(BustaPagaTest07.class); break;
case 8 : result = JUnitCore.runClasses(BustaPagaTest08.class); break;
case 9 : result = JUnitCore.runClasses(BustaPagaTest09.class);
result2 = JUnitCore.runClasses(BustaPagaTaxTest09.class);
result3 = JUnitCore.runClasses(CalcolatoreScaglioneTasseTest.class);break;
case 10 : result = JUnitCore.runClasses(BustaPagaTest10.class);
result2 = JUnitCore.runClasses(BustaPagaTaxTest10.class);break;
}
for (Failure failure : result.getFailures()) {
System.out.println(failure.toString());
count++;
}


System.out.println("\nBustaPagaTest"+buca+":");
System.out.println(result.wasSuccessful() ? "OK" : "Test con errori: "+count);

if (buca==9 || buca==10) {
for (Failure failure : result2.getFailures()) {
System.out.println(failure.toString());
count2++;
}
System.out.println("\nBustaPagaTaxTest"+buca+":");
System.out.println(result2.wasSuccessful() ? "OK" : "Test con errori: "+count2);
}

}
}
16 changes: 16 additions & 0 deletions src/bustapaga/buca01/BustaPaga.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package bustapaga.buca01;

public class BustaPaga {
private final double stip;

public BustaPaga(final double stpnd) {
this.stip = stpnd;
}

public double getNetto() {
final double pst = Math.max(Math.min(stip, 20000.0) - 5000, 0.0);
final double sst = Math.max(Math.min(stip, 40000) - 20000, 0.0);
final double tst = Math.max(stip - 40000, 0.0);
return stip - (pst * 0.1 + sst * 0.2 + tst * 0.4);
}
}
Loading