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

Koans might be more educational when inverted #264

Open
briankung opened this issue Sep 5, 2021 · 1 comment
Open

Koans might be more educational when inverted #264

briankung opened this issue Sep 5, 2021 · 1 comment

Comments

@briankung
Copy link

briankung commented Sep 5, 2021

Hi, just a thought because I'm halfway through the koans and I'm pretty sure that I have missed a lot of class (?) functions because I wasn't writing them. The asserts might be more educational when inverted, i.e. instead of:

assert Map.merge(%{first_name: "Jon"}, %{last_name: "Snow"}) == ___

it was:

assert %{first_name: "Jon", last_name: "Snow"} == Map.merge(___, ___)

Or something similar, so that when adding an answer, your eyes are drawn to the function being used.

Anyway, lovely resource, thanks for maintaining!

@iamvery
Copy link
Collaborator

iamvery commented Sep 13, 2021

Thanks for the suggestion! Very interesting idea 💡

I would say that generally speaking, the goal of lessons like this is to encourage the learner to seek out the documentation for what is not understand and use that to produce an answer. The convenient thing about pure functions is that they are deterministic (did I get that right?). That is, in this example, there is exactly one result that is produced from the given input. In the proposed form, there are many inputs that produce the same result, e.g.

  1. Map.merge(%{first_name: "Jon"}, %{last_name: "Snow"})
  2. Map.merge(%{}, %{first_name: "Jon", last_name: "Snow"})
  3. Map.merge(%{first_name: "Brian", last_name: "Kung"}, %{first_name: "Jon", last_name: "Snow"})

For that reason, I tend to think that the existing form is more concrete and therefore more enlightening. Additional examples might be included (like those listed above) to emphasize other truths, like for e.g. Map.merge overwrites existing values.

In fairness, this is my "right now" thoughts on this issue, and not necessarily based on the decision made at the time of writing the example(s).

Glad you've found this project useful! Thank you for the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants