Repository navigation
Description
Hi,
in the tests of the Etl exercise a 3rd party library (Guava) is used to create the ImmutableMap objects.
The problem with this library is that the ImmutableMap class cannot handle maps with more than 5 elements, and so the tests cases are written differently. See these two example from two test cases in this exercise:
import com.google.common.collect.ImmutableMap; //3rd party library
// from the test case testTransformMoreValues()
Map<Integer, List<String>> old = ImmutableMap.of(
1, Arrays.asList("A", "E"),
2, Arrays.asList("D", "G")
);
// from the test case testFullDataset()
Map<Integer, List<String>> old = ImmutableMap.<Integer, List<String>>builder().
put(1, Arrays.asList("A", "E", "I", "O", "U", "L", "N", "R", "S", "T")).
put(2, Arrays.asList("D", "G")).
put(3, Arrays.asList("B", "C", "M", "P")).
put(4, Arrays.asList("F", "H", "V", "W", "Y")).
put(5, Arrays.asList("K")).
put(8, Arrays.asList("J", "X")).
put(10, Arrays.asList("Q", "Z")).
build();
As you can see, the two test cases are written differently since the first one creates a map with 2 elements, while the second one a map with more than 5.
In my opinion there are two problems with these tests:
- they are incoherent and they make it hard to clearly understand the difference among the different test cases.
- These test cases could have been written also using the standard library and achieving the same result. Here below the second test cases previously mentioned, but rewritten :
Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
{
put(1, Arrays.asList("A", "E", "I", "O", "U", "L", "N", "R", "S", "T"));
put(2, Arrays.asList("D", "G"));
put(3, Arrays.asList("B", "C", "M", "P"));
put(4, Arrays.asList("F", "H", "V", "W", "Y"));
put(5, Arrays.asList("K"));
put(8, Arrays.asList("J", "X"));
put(10, Arrays.asList("Q", "Z"));
}
};
Collections.unmodifiableMap(old);
I think the point 2 is important. Exercism is mostly used by people to practice and learn new languages, and, in my opinion, it would be better to make them learn and practice the standard library. They will soon find new libraries like Guava, but - when possible - and in exercism.io it usually is, since the exercises are pretty simple - we should stick with the standard library.
It's a pity to not discover what it can provide. Up to the practitioner to discover 3rd libraries.
What do you think?
Activity
jtigger commentedon Nov 7, 2016
Love this. Your thinking about the range of tech we focus on squares with how most (all?) track maintainers (see exercism/exercism#3113).
alebaffa commentedon Nov 7, 2016
Ah, I didn't see it. Thanks.
About the test itself, shell I change it as I mentioned (so removing Guava)?
jtigger commentedon Nov 7, 2016
Yeah, it was short-lived and closed... not easy to know it's there; we're working on surfacing those formative discussions (exercism/discussions#96).
To your question, it would be great to remove this unnecessary dependency on Guava.
Thank you so much for your attention to detail, here, @alebaffa!
[-]Usage of 3rd party libraries in exercism.io[/-][+]etl: usage of 3rd party libraries in exercism.io[/+]jtigger commentedon Nov 29, 2016
Resolved by #170.