Skip to content

Conversation

@lilyqin7
Copy link

@lilyqin7 lilyqin7 commented Jan 2, 2026

Summary
This PR replaces helper functions (rollMany(), setUp()) with explicit, inline roll calls and frame comments in the bowling exercise tests. This makes tests self-contained and easier for students to understand without analyzing test infrastructure.

Problem
Students have reported confusion with the bowling exercise tests (see
this forum thread
) because helper functions like rollMany(18, 0) obscure what's actually happening in the test scenarios. Students couldn't determine which frame they were looking at or how many rolls had occurred, forcing them to analyze helper function implementations instead of focusing on bowling scoring logic.

Changes Made
Removed setUp() method - each test now explicitly creates its own $game instance

Replaced all rollMany() calls with explicit $game->roll() calls

Added frame comments (e.g., // Frame 1, // Frame 10 - Strike with two bonus rolls) to clarify game structure

Removed unused helper methods (rollMany(), rollSpare(), rollStrike())

Removed unused private $game property

Rationale
This follows the DAMP principle for test code, which prioritizes readability over DRY. While production code should avoid duplication, test code serves as documentation and benefits from explicit, self-contained scenarios. Students can now see exactly what happens in each test without switching to helper functions.

Testing
All existing tests pass without modification to assertions or test logic - only the setup/arrangement code has been expanded for clarity.

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@lilyqin7
Copy link
Author

lilyqin7 commented Jan 2, 2026

@exercism/maintainers-admin I'm not sure if I need to add the [no important files changed] message

@mk-mxp
Copy link
Contributor

mk-mxp commented Jan 2, 2026

@lilyqin7 Thanks for pushing this! I'll read through it now. You do not have to add the [no important files changed], that's on me.

Copy link
Contributor

@mk-mxp mk-mxp left a comment

Choose a reason for hiding this comment

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

That looks great! I like the structure given by the frame comments, but I think we should not give that many details in hints. Leave the math to the student, but help with the domain language.

@mk-mxp mk-mxp added x:action/improve Improve existing functionality/content x:knowledge/none No existing Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:type/content Work on content (e.g. exercises, concepts) x:size/medium Medium amount of work x:rep/medium Medium amount of reputation labels Jan 2, 2026
@mk-mxp
Copy link
Contributor

mk-mxp commented Jan 2, 2026

Not all tests pass as they did before. The failing one is testTwoRollsInAFrameCanNotScoreMoreThan10Points(), where it formerly had all rolls filled up with 0's and then called score().

The logic of the (changed) test case is actually correct, and it should be like this.

@lilyqin7 Can you adjust the example solution ./exercises/practice/bowling/.meta/example.php to pass the tests as they are now? This requires a substantial change to the code, as now the frame tracking needs to be in the roll() method as well as the score() method.

If that's too much, I would rather re-add the 0's and not break the existing solutions now.

lilyqin7 and others added 12 commits January 3, 2026 02:20
Co-authored-by: mk-mxp <55182845+mk-mxp@users.noreply.github.com>
Co-authored-by: mk-mxp <55182845+mk-mxp@users.noreply.github.com>
Co-authored-by: mk-mxp <55182845+mk-mxp@users.noreply.github.com>
Co-authored-by: mk-mxp <55182845+mk-mxp@users.noreply.github.com>
Co-authored-by: mk-mxp <55182845+mk-mxp@users.noreply.github.com>
Co-authored-by: mk-mxp <55182845+mk-mxp@users.noreply.github.com>
Co-authored-by: mk-mxp <55182845+mk-mxp@users.noreply.github.com>
Co-authored-by: mk-mxp <55182845+mk-mxp@users.noreply.github.com>
Co-authored-by: mk-mxp <55182845+mk-mxp@users.noreply.github.com>
@lilyqin7
Copy link
Author

lilyqin7 commented Jan 6, 2026

@mk-mxp I believe I have fixed the solution, could you take a look?

@mk-mxp
Copy link
Contributor

mk-mxp commented Jan 6, 2026

@lilyqin7 Thank you very much! The code style checker has detected a lot of whitespace issue. Do you have a setup where you can install and run the code style tool?

If your setup does not allow that, I could do that for you.

@lilyqin7
Copy link
Author

lilyqin7 commented Jan 6, 2026

@mk-mxp should be fixed now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

x:action/improve Improve existing functionality/content x:knowledge/none No existing Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:rep/medium Medium amount of reputation x:size/medium Medium amount of work x:type/content Work on content (e.g. exercises, concepts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants