Skip to content

grade-school test for student in multiple grades does not make sense #1763

Closed
@wolf99

Description

@wolf99

"description": "A student can't be in two different grades",

Firstly this test has desiredGrade as an input, but is a test of the roster property, this input is otherwise only used with the grade property. This does not make sense in terms of the functionality required for the properties

students_t roster(input); // this case, and only this case, implies adding desired_grade argument here also, which does not make sense
students_t grade(input, desired_grade);

This seems like possibly just a mistake of copy-pasta roster when grade was intended. Thus the solution would be simply to change the property under test from roster to grade. I can add a PR to resolve this if I have understood correctly?

A second issue is that the students input is intended, per the README.md, one by one. This implies some order of addition. The order used does not matter, just that there must be one.
However, the desiredGrade is then queried later.
So a function used to add students (e.g. add_student(student_t student) ) could check inputs for duplicate names, but it can only prevent second and third additions. It cannot know in advance of adding the first name that a second name will be added that will conflict with it.

Thus the input of the following cannot make sense given that the desiredGrade, that should return an empty roster, is the first student to be added:

            "students": [
              ["Aimee", 2],
              ["Aimee", 1]
            ],
            "desiredGrade": 2

If instead, we say that addition of students should not be filtered, but instead the grade() function should filter what gets output from the data that has been added; then yes, this can work, but it is ugly and requires poor implementation in just about any language I know (true, I don't know a lot of languages 😄 ).

A solution to this problem can be that the README.md is added to remove suggestions about what implementation should be - just describe the problem and let languages implement a solution in an idiomatic manner. Is this correct understanding, maybe I have missed something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions