-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
bowling: should we be precise about which roll, specifically, is erroneous? #440
Comments
|
|
|
I had a hard time trying to discover why I had the feeling that something was strange in this exercise! Now that I had some more time to think about it, I'll try to make a proper comment. 😄 About x-commonIn x-comon there is something about a method Because of that, instead of not testing for intermediary functions, this object-oriented specification seems to promote testing just for intermediary functions. A more direct specification would probably only ask for a So, considering what was discussed in exercism/discussions#41 and exercism/discussions#44, I think that the specification is over-prescriptive and deserves to be changed. Of course, I'm saying this from the perspective of a Haskell enthusiast. About our current implementationIt is hard to transform object-oriented programming in functional programming, but I would risk saying that @abo64's implementation of That said, it unavoidably suffers a little from over-prescriptiveness, as the source. About the proposed changesI consider your proposal to change the signature of But before following that path, I would like to question if we should keep testing An alternativeWhat do you guys think about these signatures? score :: [Int] -> Maybe Int
score :: [Int] -> Either String Int We could take @petertseng's idea of ignoring the contents when it is a data BowlingError = IncompleteGame
| InvalidRoll (Int, Int)
score :: [Int] -> Either BowlingError Int |
Actually the Scala version uses |
ok, then I will implement these changes within the next few days. |
I guess it would be nice to wait a little until @petertseng says what he thinks about it. |
Don't wait for me too long while I still have limited access (but in this case y'all got lucky) So I think |
sorry @petertseng I was too quick here. Something like data BowlingError = IncompleteGame
| InvalidRoll { rollIndex :: Int, rollValue :: Int } ? |
Seems good if that's what you were thinking. Happy to defer to @rbasso if has a different idea, but it was my best guess from seeing two ints. |
And it was my best guess, too. :-) |
I'm fine with either, ignoring the Left content or demanding invalid roll's index and value. So everybody agrees with diverging from x-common?! |
Surprisingly, I do. I think the diversion is reasonable and is better suited for our track. And it is not so bad - we haven't diverged in the actual test cases, only how they are tested (omitting a Any records of past diversions? I see one in crypto-square. But there is an interesting point - the README can now be confusing for students if we only test the And/or: Shall we propose making the x-common README less prescriptive? |
In x-common, I guess that removing the section |
I remember vaguely for some exercise (was it Linked List?) a distinction in the Readme for functional and imperative languages where for the former they relaxed the requirements to some extent? But I couldn't find it anymore. |
All I know is that exercism/problem-specifications#193 is still open. |
Take, for example, the sequence of rolls
[5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
In this, we would expect the 6 is the erroneous roll. By this, we mean that if
game = roll 6 (roll 5 bowlingStart)
, no matter what you do togame
you cannot get a score out of it.The tests don't test that precisely - they currently cannot, since
roll
returns aBowling
, and there is no way to determine the above-described property of aBowling
without trying toroll
it to completion.So my question is: Would we like to be more precise about which roll is erroneous?
(I have argued the same in the Rust implementation)
The gist is that I like to fail fast and close to the source of the error, so that it is easy to understand what caused the error.
If we find this desirable, some proposals to do it:
isValid :: Bowling -> Bool
. I find this a little unclean.roll
's type toroll :: Bowling -> Int -> Either ___ Bowling
(the ___ can be any user-defined error they like; the tests only need to testisLeft
on it)And a final question:
Should this be brought to x-common? Note that there will be a slight challenge in how to represent the "this specific roll should fail" in JSON (my current leading thought is keeping the
rolls
array but then adding aroll_should_fail
entry)The text was updated successfully, but these errors were encountered: