-
-
Notifications
You must be signed in to change notification settings - Fork 697
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
dnd-character: Suggestions for improving constructor in stub and in reference solution #1671
Comments
Thank you @sshine for bringing this to our attention. I will add the missing constructor to the stub file as soon as possible. Regarding the Also I am wondering if a reference solution with dependency injection of Maybe it would be warranted to increase the level of difficulty from 2 to 3 or 4. |
Because it depends on only its input, not on any object properties. Since you don't need the context of an object to compute the function, the minimal implementation would be a static method. Compare this to the Haskell solution, the C# solution and the Python solution where they're respectively a pure function independent of the |
Agreed, thank you @sshine . I will add the |
OK, that is completely reasonable.
To be honest, I'm not very proficient with testing randomness via dependency injection; it was a topic I got involved with at work and have tried to find a good solution for. Otherwise I am only influenced by the principle of removing side-effects from functions to make them predictable, since this is the default in functional programming. I suppose that if you mock
although it wouldn't cover the logic of picking the least three. Having a deterministic, mock The way the Java track tests that abilities are correct is the same way I've made the Haskell track do it, since property-based testing and mocking are, as far as I can see, orthogonal approaches. :-) |
@sshine @lemoncurry As for making the method static, we currently have a policy to prefer instance methods. Policies are of course always up for discussion and can be changed, but in that case I think that should be a separate issue 🙂 I agree that injecting |
Also @sshine @lemoncurry why do you feel adding the constructor to the stub file would be an improvement? In general we only add enough code to the stub file so that you can run the tests without any compiler errors. As the constructor doesn't take any arguments, you don't need one for the tests to compile. And, correct me if I'm wrong as I haven't done this exercise, I don't think you necessarily need to implement a custom constructor to make all the tests pass. So we shouldn't necessarily be pushing users to a solution involving a custom constructor 🙂 |
Thank you @FridaTveit for raising these important points. Yes, it would not be necessary to add a stub for the constructor to pass the tests.
So with required it is implied required to pass the tests without compiler error? Regarding static methods, after reading the discussion that is referenced, I would agree to stay with this policy and stay with instance methods. |
Sorry, it's probably not described very well. Feel free to update it to something that's more clear 🙂 |
@FridaTveit: Thank you for asking.
That seems reasonable, although I think it might also cause some students to not know where to start. Another way would be to provide a track-specific hint that suggests how to proceed. There could be yet other ways. I'll elaborate on why I recommended the constructor in the stub: So as far as I can tell, a mentor on the C track, Mayur, wrote the following on Slack:
This suggests to me that there's a gap in the way the exercise is understood. To elaborate on my initial comment, "I suspect that adding a constructor to the stub file would improve the situation": This might indicate to the student that a starting point, and the meat of the exercise, is in the constructor. So I think providing a constructor in the stub file would make the most important placeholder visible and move focus to the meat of the exercise, as opposed to figuring out where to place the die-rolling code. Finding out where to begin is not something that has a high learning / time spent ratio. You also wrote:
That's certainly true.
I don't think you can solve the problem of randomly generating stats, save them and access them again without a custom constructor. So I suppose that the criterion of having the minimal stub that compiles the test may sometimes conflict with the didactic arguments that I present. (The rest of this reply consists of personal anecdotes with minimal or non-existent stubs being the cause of problems. Feel free to disregard them.)
|
If people are struggling with the exercise then we should definitely try to do something to help, so thanks for raising that @sshine 🙂 But I don't think we should be pushing users towards a certain solution. Upping the difficulty so that it more accurately reflects how hard the exercise is would be one improvement. I also like your idea of providing a track specific hint. We already do that for other exercises (e.g. https://github.com/exercism/java/blob/master/exercises/list-ops/.meta/hints.md) so I think that would be a good idea here as well 🙂 |
OK. I'm not sure I can imagine more than one solution besides the one where I believe I've left enough of an impression without contributing code to the solution, so I'll bid you a good day now. :-D |
Mayur on Slack said that the DND Character exercise was hard to figure out.
I suspect that adding a constructor to the stub file would improve the situation.
As for the
modifier
method, shouldn't this be a static method?And as for the reference solution, I would suggest the improvement to have
Random
dependency-injected into the constructor, since otherwise you can only do probabilistic testing, as is done now.The text was updated successfully, but these errors were encountered: