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 book-store #842

Open
4 tasks done
Tracked by #628
mk-mxp opened this issue Nov 7, 2024 · 6 comments · May be fixed by #850
Open
4 tasks done
Tracked by #628

Sync book-store #842

mk-mxp opened this issue Nov 7, 2024 · 6 comments · May be fixed by #850
Assignees

Comments

@mk-mxp
Copy link
Contributor

mk-mxp commented Nov 7, 2024

  • Run bin/configlet sync -u -e book-store --yes --docs --filepaths --metadata --tests include (updates the Markdown files and maybe tests.toml)
    • docs: instructions unsynced: book-store
  • Drop strict types comments from test file and example code (these are useless)
  • Add and sync test meta data to tests (uuid / @testdox in DocBlocks)
  • Decide on adding / adjusting / ordering test cases to match current problem specs
    • book-store: missing 3 test cases

Do not redesign the student's interface or add test cases that would invalidate existing community solutions. These are extra tasks, which should be discussed in advance.

@tomasnorre tomasnorre self-assigned this Nov 8, 2024
@tomasnorre tomasnorre linked a pull request Nov 8, 2024 that will close this issue
@mk-mxp
Copy link
Contributor Author

mk-mxp commented Nov 9, 2024

OK, this exercise has some complicated issues...

  1. The canonical data states "implementors should use proper fixed-point or currency data types of the corresponding language and not float." Our implementation currently uses float. We may opt to use int and cents as the canonical test data contains them already or continue using float.
  2. assertEquals() is not appropriate for float values. There is assertEqualsWithDelta() for floating point comparison. This might already make the current example code pass the tests.
  3. The missing tests seem to be those that "optimize" the price for cases with 5 different books but a group of 5 is not the optimum. I do not know the history of the exercise, but these seem to be added to catch edge cases of optimizing. I think we should have them.

Any additional findings / thoughts?

@tomasnorre
Copy link
Contributor

My 5cents.

  1. I would go for int as that is the right way to handle amount in PHP, if not using a money library.

  2. The assertEqualsWithDelta() would not be needed then.

  3. I think we should include all test cases, en ever exercise, unless there are some functionality in PHP making it super hard or impossible.

I have forgotten have to look up how many people have already solved the exercise, and how many it would break for.

@mk-mxp
Copy link
Contributor Author

mk-mxp commented Nov 12, 2024

There is 61 solutions, only ~40% of 153 people who tried this. So this should be improved.

@homersimpsons Your opinion about 1. / 2.? Proper float comparison or using int instead?

@homersimpsons
Copy link
Contributor

homersimpsons commented Nov 13, 2024

@homersimpsons Your opinion about 1. / 2.? Proper float comparison or using int instead?

I know I always prefer int for monetary values. I think it is a good way to show students that this could be used and avoids most rounding issues. It may helps them in the future too when they will handle monetary values.

I would prefer to avoid float here. Another alternative could be to use BCMath.

So my vote is (from most preferred to least preferred) int > bcmath >> float.

There is 61 solutions, only ~40% of 153 people who tried this. So this should be improved.

61 solutions looks fine for me to change this completely.

@mk-mxp
Copy link
Contributor Author

mk-mxp commented Nov 14, 2024

OK, thanks everybody. We agreed on int and as we break existing solutions with that we will have all test cases with exactly the data from canonical data. @tomasnorre please continue with the PR.

@tomasnorre
Copy link
Contributor

I'll take care tomorrow or beginning of next week.

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 a pull request may close this issue.

3 participants