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 nucleotide-count with problem-specifications #550

Merged
merged 7 commits into from
Nov 15, 2022

Conversation

kytrinyx
Copy link
Member

@kytrinyx kytrinyx commented Nov 15, 2022

This brings the nucleotide-counts exercise up to date with problem-specifications.

For clarity, it makes the change in several commits:

  1. Delete entries from tests.toml that are not reflected in the test suite (per Update each tracks tests.toml file #370)
  2. Delete tests from the nucleotide-count test suite that do not have equivalents in the canonical-data.json
  3. Reorder nucleotide-count tests to reflect the order in canonical-data.json
  4. Run configlet fmt on nucleotide-count to normalize the config.json
  5. Normalize nucleotide-count tests to use the inputs and test descriptions from the canonical data.
  6. Run configlet sync for the exercise and implementing the missing test.

Closes #544
Closes #539

This removes an unimplemented test from the tests.toml.
This deletes some tests that are not in the canonical-data in
problem-specifications.
This reorders the tests to match the order in the canonical-data.
This reformats the config.json to make configlet happy.
This updates the existing tests to use the inputs and test names from
canonical-data.
This brings the nucleotide-count exercise up to date with
the specification in problem-specifications.

The sync brought in changes to the instructions and metadata,
as well as adding a new test.
The tests no longer reference the count function.
This deletes it.
@kytrinyx kytrinyx changed the title sync nucleotide counts Sync nucleotide-count with problem-specifications Nov 15, 2022
This was referenced Nov 15, 2022
@kytrinyx kytrinyx marked this pull request as ready for review November 15, 2022 11:28
@kytrinyx kytrinyx merged commit 4f60551 into main Nov 15, 2022
@kytrinyx kytrinyx deleted the sync-nucleotide-counts branch November 15, 2022 16:15
@siebenschlaefer
Copy link
Contributor

I completely missed this back in November.

Previously implementing this task with a class made sense. A counter object gets initialize once, then its member functions nucleotide_counts() and count() can be called a number of times. I often discussed with my students where the actual counting should happen, in the constructor or in the member functions.

Now that the member function count() is gone, (conceptually) it's a two-step function call: Construct the instance (which performs some validation), then call nucleotide_counts() with returns the counter. I find that a little bit strange.

To me that looks now like a task for a regular function that performs the validation (it might throw) and then returns the std::map.
Is there a reason to implement this as a class?

@kytrinyx
Copy link
Member Author

Is there a reason to implement this as a class?

Probably not! I was likely just following what was already there, and then tweaking it to follow the current canonical data. I don't actually write C++, and I don't even remember making this PR (which is a bit disconcerting).

Please feel free to change the implementation, if you have something better in mind.

siebenschlaefer added a commit to siebenschlaefer/exercism-cpp that referenced this pull request Mar 14, 2023
Before PR exercism#550 the constructor was required to validate the input, the
member function `count(char)` had to return the count for a specific
nucleotide, the member function `nucleotide_counts()` had to return a
`std::map` with all four counts.

But PR exercism#550 has changed that significantly. After syncing the tests with
the canonical data there's no call to `count(char)` anymore, so each
test looks like a two-step function call:

```
const nucleotide_count::counter dna("G");
const auto actual = dna.nucleotide_counts();
```

I'd call that unnecessarily complicated and unidiomatic, there's
no longer a good reason to require a `class`. Let's turn the class
`counter` into a function:

```
const auto actual = nucleotide_count::count("G");
```
vaeng pushed a commit that referenced this pull request Mar 15, 2023
Before PR #550 the constructor was required to validate the input, the
member function `count(char)` had to return the count for a specific
nucleotide, the member function `nucleotide_counts()` had to return a
`std::map` with all four counts.

But PR #550 has changed that significantly. After syncing the tests with
the canonical data there's no call to `count(char)` anymore, so each
test looks like a two-step function call:

```
const nucleotide_count::counter dna("G");
const auto actual = dna.nucleotide_counts();
```

I'd call that unnecessarily complicated and unidiomatic, there's
no longer a good reason to require a `class`. Let's turn the class
`counter` into a function:

```
const auto actual = nucleotide_count::count("G");
```
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.

3 participants