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

Sync robot-simulator #784

Merged
merged 13 commits into from
Aug 3, 2024
Merged

Sync robot-simulator #784

merged 13 commits into from
Aug 3, 2024

Conversation

mk-mxp
Copy link
Contributor

@mk-mxp mk-mxp commented Jul 27, 2024

Sync'ed according to #781. Changes tests heavily in structure, but not and in content. So no re-testing against existing solutions required.

  • Spread out test cases to individual test methods
  • Test only from the interface specified in problem specifications
  • Still Re-design as discussed in Re-design robot-simulator #783

I did find a way to do a re-structuring without altering the interface relied on by existing solutions. There are now no extra methods used, that I think were older than the current instructions property in problem spec.

The exercise is marked as topic: ['oop'] in config.json, which hints on why there were specialised methods to change the internal state. And why our example.php (and an additional test) does method chaining (fluent interface design).

To stay as close to the problem spec as possible, the OOP-isms are seemingly superfluous. A fluent interface design deviates totally from the string style instructions. On the other hand one could transform the string input into the fluent interface while writing the tests, and also allow immutable instances as a more modern approach that way. But still, I think such OOP-isms should only be in additional PHP track exercises.

Also spreads tests out to indepent test methods, uses only the defined
interface from problem spec and still is compatible with existing
solutions.
README translates to instructions nowadays
@mk-mxp mk-mxp added x:action/sync Sync content with its latest version x:knowledge/elementary Little Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:type/content Work on content (e.g. exercises, concepts) x:size/small Small amount of work x:rep/small Small amount of reputation labels Jul 27, 2024
@mk-mxp mk-mxp self-assigned this Jul 27, 2024
Copy link

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!

@mk-mxp
Copy link
Contributor Author

mk-mxp commented Jul 28, 2024

@fejan-malek I cannot add you as a reviewer, because you are no maintainer yet. Anyways, what do you think about a fluent interface here?

@fejan-malek
Copy link
Contributor

@mk-mxp I agree with using a fluent interface because it helps write clean code, better code readability, and reduces code complexity.

What do you think about the existing solution already submitted in this exercise? Is it gonna affect these changes?

@mk-mxp
Copy link
Contributor Author

mk-mxp commented Jul 29, 2024

What do you think about the existing solution already submitted in this exercise? Is it gonna affect these changes?

@fejan-malek Not using an implemented method does not invalidate any existing solution.

@mk-mxp mk-mxp mentioned this pull request Jul 29, 2024
2 tasks
@mk-mxp
Copy link
Contributor Author

mk-mxp commented Jul 29, 2024

I've been trying out several variants for a fluent interface. The problem is, that all the benefits of the fluent interface are hidden in the tests. The student experiences nothing but "additional work to return $this".

The exercise becomes rather "boring", with only conditionally adjusting values. "Boring implementation" can be a quality of good design, but is discouraging for students at Exercism. There would be only one challenge left in the exercise. The string splitting and looping disappears.

These two points made me decide: The exercise shall stay as close as possible to problem specifications. Fluent interfaces are a concept to introduce in an extra exercise, most likely a PHP track only exercise.

@homersimpsons
Copy link
Contributor

Note that I didn't took time to take a look yet, I will probably look into this tomorrow.

About fluent interfaces I'm not in favour of having those: https://ocramius.github.io/blog/fluent-interfaces-are-evil/

That said it could be great to introduce them in an exercise just so the students know they can write code like this and understand how to read code like this.

Copy link
Contributor

@homersimpsons homersimpsons left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. I will take a look into #783, I think it would make sense to think about the re-design first so newly published solutions will remain correct in the short future.

exercises/practice/robot-simulator/RobotSimulator.php Outdated Show resolved Hide resolved
exercises/practice/robot-simulator/RobotSimulator.php Outdated Show resolved Hide resolved
This takes the exercise closer to problem specifications
This breaks all existing solutions.
This provides proper encapsulation. Also breaks all existing solutions.
- Remove dead code
- Adhere to interface of student stub
- Type annotations, typos, code order
Copy link
Contributor

@homersimpsons homersimpsons left a comment

Choose a reason for hiding this comment

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

Just a small comment, but I'm okay with the current changes. Thank you for the changes !

exercises/practice/robot-simulator/.meta/example.php Outdated Show resolved Hide resolved
OK, that's pedantic. But computers are pedantic.
@mk-mxp mk-mxp merged commit 76a8d8a into exercism:main Aug 3, 2024
12 checks passed
@mk-mxp mk-mxp deleted the sync-robot-simulator branch August 3, 2024 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/sync Sync content with its latest version x:knowledge/elementary Little Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:rep/small Small amount of reputation x:size/small Small 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.

3 participants