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

Update bowling canonical-data #391

Merged
merged 5 commits into from
Oct 16, 2016

Conversation

IanWhitney
Copy link
Contributor

@IanWhitney IanWhitney commented Oct 2, 2016

This is based on my work implementing this problem for Rust
exercism/rust#213

I'm addressing a few things here.

  • The description at the top is now about implementing the tests, not
    about the problem domain.
  • I've reordered the test to (hopefully) make things flow more smoothly.
    I found that the previous set of tests introduced concepts in kind of a
    mix, instead of one at a time.

They are now:

  • Score a 0 point game
  • Score a game with no spares/strikes
  • Spares
    • Simple spare
    • Spare with bonus
    • Spare in last frame
  • Strikes
    • Simple strike
    • Strike with bonus
    • Strike in last frame
  • Exceptions

Some other changes:

  • Updated descriptions. My goal here was to try to clearly state what
    bit of scoring logic was being tested in each test, without relying too
    much on bowling-specific terms. 'strike', 'spare' and 'frame' are
    unavoidable, but other terms were replaceable.
  • Remove unnecessary tests. There were a few different tests of games
    without spares & strikes when only one is really necessary. My goal is
    that each test should lead the student to make one change to their code.
    If a bunch of tests can pass because of the same change then some of
    those tests can be removed.
  • Explicit description of arity removed. I tried to cover the expected
    API in the description text.
  • Expectations of exceptions changed from specific error text to -1,
    which is what I normally see for exception test definitions.

This is based on my work implementing this problem for Rust
exercism/rust#213

I'm addressing a few things here.

- The description at the top is now about implementing the tests, not
about the problem domain.

- I've reordered the test to (hopefully) make things flow more smoothly.
I found that the previous set of tests introduced concepts in kind of a
mix, instead of one at a time.

They are now:

- Score a 0 point game
- Score a game with no spares/strikes
- Spares
  - Simple spare
  - Spare with bonus
  - Spare in last frame
- Strikes
  - Simple strike
  - Strike with bonus
  - Strike in last frame
- Exceptions

- Updated descriptions. My goal here was to try to clearly state what
bit of scoring logic was being tested in each test, without relying too
much on bowling-specific terms. 'strike', 'spare' and 'frame' are
unavoidable, but other terms were replaceable.

- Remove unnecessary tests. There were a few different tests of games
without spares & strikes when only one is really necessary. My goal is
that each test should lead the student to make one change to their code.
If a bunch of tests can pass because of the same change then some of
those tests can be removed.

- Explicit description of arity removed. I tried to cover the expected
API in the description text.

- Expectations of exceptions changed from specific error text to `-1`,
which is what I normally see for exception test definitions.
Copy link
Member

@kytrinyx kytrinyx left a comment

Choose a reason for hiding this comment

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

This is a huge improvement!

"Students should implement roll and score methods.",
"Roll should accept a single integer.",
"Score should return the game's final score, when possible",
"For brevity the tests all the rolls in an array;",
Copy link
Member

Choose a reason for hiding this comment

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

This sentence might be missing a word, and I can't figure out what it should be. Holds? Keeps? Stores?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the tests contain all the rolls in an array, probably.

"For brevity the tests all the rolls in an array;",
"each element of the rolls array should be passed to the roll method",
"The final tests define situations where the score can not be returned",
"The expection for these tests is -1, indicating an exception",
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps s/exception/error state. Some languages will implement this as an exception, but others might not (e.g. Go doesn't have exceptions).

}, {
"description": "should not allow two normal rolls better than strike in last frame",
"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6],
Copy link
Member

Choose a reason for hiding this comment

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

any value in keeping these? it did catch an oversight in my code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If these tests caught an edge case, then they should be kept. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

I was indeed treating the bonus rolls in a separate place from the normal ten frames, so I do say it is worth keeping.

}, {
"description": "should not allow rolls after the tenth frame",
"description": "A game with more than ten frames can not be scored",
Copy link
Member

@petertseng petertseng Oct 8, 2016

Choose a reason for hiding this comment

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

The change in the description seems to change the implication of where the error should occur.

Before, to me this sounds like: The roll should be rejected before there is any attempt to take the score.

After, it sounds like: The roll should be accepted, and only when taking the score do we realize there is a failure.

And I definitely think the roll should be rejected as soon as possible.

But this is a difficult proposition when the only expectation this test file expresses is the score at the end, instead of noting where the error should occur. That's a difficult concept to express though. The first idea that comes to mind (and the idea may be crazy) is:

"rolls": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"roll_should_fail": 0,

If the idea is accepted, it can also be used for the [5, 6] roll.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For those of you who aren't Peter, we've been talking about this in the Rust PR as well.

exercism/rust#213

For Rust, at least, we're going to have the roll method fail if the roll is invalid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can update the description to talk about this decision. I think the json file can mention it, but leave it up to the implementation.

Copy link
Member

@petertseng petertseng Oct 12, 2016

Choose a reason for hiding this comment

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

I can update the description to talk about this decision. I think the json file can mention it, but leave it up to the implementation.

Seems good.

@IanWhitney
Copy link
Contributor Author

I think I've covered the comments to date.

@IanWhitney IanWhitney merged commit 9049dc7 into exercism:master Oct 16, 2016
@IanWhitney IanWhitney deleted the update_bowling_tests branch January 14, 2017 19:10
emcoding pushed a commit that referenced this pull request Nov 19, 2018
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.

None yet

4 participants