Skip to content

Add hangman exercise. - #1758

Merged
jmrunkle merged 24 commits into
exercism:masterfrom
Kineolyan:add-hangman-exercise
May 6, 2020
Merged

jmrunkle merged 24 commits into
exercism:masterfrom
Kineolyan:add-hangman-exercise

Conversation

@Kineolyan

Copy link
Copy Markdown
Contributor

Closes: #1745


Reviewer Resources:

Track Policies

@Kineolyan
Kineolyan marked this pull request as ready for review October 4, 2019 12:28
@Kineolyan

Copy link
Copy Markdown
Contributor Author

There is still the issue of the installation of the FRP library. See this comment in the issue.

@lemoncurry

lemoncurry commented Oct 12, 2019 •

Copy link
Copy Markdown
Contributor

There is still the issue of the installation of the FRP library. See this comment in the issue.

I restarted the build because the error referred to a previous problem and will have a look at the log file. It should be sufficient to add the dependency in build.gradle as you did.

EDIT: @Kineolyan Everything seems fine now, build is passing. I will review your PR in the coming week, sorry for the long wait! Thank you again for contributing 😄

@lemoncurry
lemoncurry self-requested a review October 12, 2019 16:23
@Kineolyan

Copy link
Copy Markdown
Contributor Author

Thanks @lemoncurry . Indeed, I am glad to see it pass. I will also give it a review, from what I learn of previous PRs on that project.

@lemoncurry lemoncurry left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Kineolyan ! I think this is a very impressive PR. FRP is not very well known, and, to be honest, I cannot truly review how you implemented this exercise. Maybe someone of @exercism/java is more familiar with FRP?

@Kineolyan Maybe you could tell me how you approached this exercise? Were you already familiar with FRP?

Comment thread config.json Resolved
Comment thread config.json Resolved
Comment thread config.json Resolved
@Kineolyan

Copy link
Copy Markdown
Contributor Author

Hello @lemoncurry I did several small personal projects using various frameworks for FRP.

I can guide you in the implementation and the key elements I wanted in my solution. Do you think some of the explanations should be part of the README or something? I will look at the other exercises, to find one that is similarly complex.

And I will address your various comments.

@lemoncurry

Copy link
Copy Markdown
Contributor

Hello @lemoncurry I did several small personal projects using various frameworks for FRP.

I can guide you in the implementation and the key elements I wanted in my solution.

That would be great 👍

Do you think some of the explanations should be part of the README or something?

Yes, I agree. For this we have the hints.md file which will be integrated by the configlet tool when creating the README.md

@Kineolyan

Copy link
Copy Markdown
Contributor Author

Hello @lemoncurry , I have finally some time to write my comments on code.

My understanding of FRP is that the code is written using streams, that are list of events, sometimes yet to be generated. And the functional part means we should avoid side effects as much as possible.
That's why the function to write receives two inputs:

  • letters: the letters typed by the player guessing the word,
  • words: the words to guess, like what a game engine would produce. The idea for not limiting the exercise to letters is to introduce new events at the end of a game, not to have trainees consume all letters and do the work.

In the design, the class Output is designed as the whole state for a front-end describing the complete state fo the application. This way, the UI could also be functional. Even if it is not part the exercise, it fits logically in the design.

Unit tests covers basic cases in the interaction, though it still requires for the trainees to be able to use streams a bit.
I tried to make them as unitary as possible. The first check the very first state emitted. Others check the last state after one typed letter.
The final test was the most complex to write, as I had to coordinate the emission of the values. Even if the programmer should not care about this, for consistency, I had to send the first word to guess, the letters to play the game, the second word and all letters for the second guess. This is not that complex once said this way, but one has to play with the internals of RxJava lib to do so.

Finally, one quick note about my implementation: I use a reduce method as an infinite loop dealing with the inputs. It either resets the state for a new game - createNewGame - or process the input letter - processNewLetter.

I saw examples of hints.md. I will write one, as well as update the difficulty and try to find an exercise to unlock.

@Kineolyan

Copy link
Copy Markdown
Contributor Author

I normally address all your requests for change. Tell me if you need anything more.

@lemoncurry

Copy link
Copy Markdown
Contributor

@Kineolyan Thank you for your explanations and commits! I am sorry that I haven't had time yet for a closer look. I hope I will be able for a next review the coming days. Thank you for your patience!

@Kineolyan

Copy link
Copy Markdown
Contributor Author

Don't worry @lemoncurry . I am waiting for you to have some time for this 😃

@jmrunkle

Copy link
Copy Markdown
Contributor

@lemoncurry - are you still available to do this review? Or should one of the other maintainers take over?

@Kineolyan

Copy link
Copy Markdown
Contributor Author

Hello @jmrunkle I am also ready for the review.

@jmrunkle

Copy link
Copy Markdown
Contributor

It looks like lemoncurry is no longer an active reviewer, so I'll take a look at this in the morning. Thank you for your patience!

@jmrunkle jmrunkle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some API things I commented on and some general thoughts about the reference solution (those are more optional).

Thanks again for working on this (it's a really good exercise).

Comment thread config.json Resolved
Comment thread exercises/hangman/.meta/HINTS.md Resolved
@Kineolyan

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I'll address the comments and suggestions as soon as possible.

@jmrunkle

Copy link
Copy Markdown
Contributor

Thanks for the review. I'll address the comments and suggestions as soon as possible.

Thank you for contributing. Please give me an @ mention when you are ready for another look.

@jmrunkle

Copy link
Copy Markdown
Contributor

@Kineolyan - are you still working on this PR?

@Kineolyan

Copy link
Copy Markdown
Contributor Author

Almost. I forgot about it this week but I shall address your last comment about t the doc and resubmit to your review

@Kineolyan

Copy link
Copy Markdown
Contributor Author

Hello @jmrunkle I haven't found time this week but I'll try to find some time this week. As often, it was the hints documentation that was not driving me to work. But thanks to your latest comments, I see clearly how to improve the reference code. And i'll do my best with the doc.
I plan to have something for you to review by the end of the weekend.

@Kineolyan

Copy link
Copy Markdown
Contributor Author

@jmrunkle I have hopefully addressed every of your comments in a way that suits you. The PR is ready for a second review and tests are passing.

Comment thread exercises/hangman/build.gradle Resolved
@Kineolyan

Kineolyan commented May 5, 2020 •

Copy link
Copy Markdown
Contributor Author

@jmrunkle thanks to the new jdk config, I used immutable copies. And I moved to assertj for tests with failures.

@jmrunkle jmrunkle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good enough for me. Thanks for working on this!

Comment on lines +47 to +49
new HashSet<>(),
new HashSet<>(),
new ArrayList<>(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are mutable. Set.of() and List.of() would get you the immutable ones.

@jmrunkle
jmrunkle merged commit 7ebd839 into exercism:master May 6, 2020
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

Successfully merging this pull request may close these issues.

hangman: implement exercise

4 participants