First example:
countryRepository.getCountriesFromAsiaWhereAreTheMostPlanesAndBoats();
countryRepository.getCountriesFromAfricaWhereAreTheMostCars();
Are these names too big? How else do we call these functions?
I was thinking about parameters, but according to Martin Fowler, it's better not to use parameters in functions.
Second example:
I have to use these two variables in the class:
public static class CompareCountries {
public String[] countriesFromAsiaWhereAreTheMostPlanesAndBoats;
public String[] countriesFromAfricaWhereAreTheMostCars;
public CompareCountries (String countriesFromAsiaWhereAreTheMostPlanesAndBoats, String[] countriesFromAfricaWhereAreTheMostCars){
this.countriesFromAsiaWhereAreTheMostPlanesAndBoats = countriesFromAsiaWhereAreTheMostPlanesAndBoats;
this.countriesFromAfricaWhereAreTheMostCars = countriesFromAfricaWhereAreTheMostCars;
}
public static String[] compares() {}
}
Here the more I can not use parameters.
SELECT * FROM Countries WHERE Continent = 'Asia' ORDER BY NumPlanes + NumBoats DESC LIMIT 1
.addContinent(continent)
method, and then acompare()
method. The method to setup the class wouldn't even have to be tested as it would by default be tested through testingcompare()
. And the class would scale a lot more.