Skip to content

etl: usage of 3rd party libraries in exercism.io #168

Closed

Description

@alebaffa

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:

  1. they are incoherent and they make it hard to clearly understand the difference among the different test cases.
  2. 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

  1. jtigger commented on Nov 7, 2016

    @jtigger
    Contributor

    Love this. Your thinking about the range of tech we focus on squares with how most (all?) track maintainers (see exercism/exercism#3113).

  2. alebaffa commented on Nov 7, 2016

    @alebaffa
    Author

    Ah, I didn't see it. Thanks.
    About the test itself, shell I change it as I mentioned (so removing Guava)?

  3. jtigger commented on Nov 7, 2016

    @jtigger
    Contributor

    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!

  4. changed the title [-]Usage of 3rd party libraries in exercism.io[/-] [+]etl: usage of 3rd party libraries in exercism.io[/+] on Nov 29, 2016
  5. jtigger commented on Nov 29, 2016

    @jtigger
    Contributor

    Resolved by #170.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions