-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
Robot simulator descriptions too long #1525
Robot simulator descriptions too long #1525
Conversation
Convert long descriptions into comments per... per #1473
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that these changes are simply making the descriptions shorter for the sake of being shorter. I don't actually think there was anything wrong with any of these descriptions.
I'm also not a fan of the context-requiring descriptions.
"description": "at negative position facing South",
"comments": [ "Negative positions allowed" ],
This will not yield the same test result description. This one could be renamed to "Allows negative positions"
. Similarly "Create"
is not a good description. "Creation" could be okay, but I prefer "Creates a robot with position and direction"
I don't know why we want single word or 3 word descriptions. You lose a lot of information in the test suite this way.
"description": "Series of instructions", | ||
"comments": [ "The robot can follow a series of instructions and end up with the correct position and direction.", | ||
"Where R = Turn Right, L = Turn Left and A = Advance" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review. Some background....
Pharo generates individual method names for each unit test to be unique and fully descriptive by cascading the layers of descriptions. This works for all but a few exercises like robot-simulator, for which methods names arise as follows...
test01_ARobotIsCreatedWithAPositionAndADirectionRobotsAreCreatedWithAPositionAndDirection
test02_ARobotIsCreatedWithAPositionAndADirectionNegativePositionsAreAllowed
test03_RotatesTheRobotsDirection90DegreesClockwiseChangesTheDirectionFromNorthToEast
test04_RotatesTheRobotsDirection90DegreesClockwiseChangesTheDirectionFromEastToSouth
test05_RotatesTheRobotsDirection90DegreesClockwiseChangesTheDirectionFromSouthToWest
test06_RotatesTheRobotsDirection90DegreesClockwiseChangesTheDirectionFromWestToNorth
test07_RotatesTheRobotsDirection90DegreesCounterclockwiseChangesTheDirectionFromNorthToWest
test08_RotatesTheRobotsDirection90DegreesCounterclockwiseChangesTheDirectionFromWestToSouth
test09_RotatesTheRobotsDirection90DegreesCounterclockwiseChangesTheDirectionFromSouthToEast
test10_RotatesTheRobotsDirection90DegreesCounterclockwiseChangesTheDirectionFromEastToNorth
test11_MovesTheRobotForward1SpaceInTheDirectionItIsPointingIncreasesTheYCoordinateOneWhenFacingNorth
test12_MovesTheRobotForward1SpaceInTheDirectionItIsPointingDecreasesTheYCoordinateByOneWhenFacingSouth
test13_MovesTheRobotForward1SpaceInTheDirectionItIsPointingIncreasesTheXCoordinateByOneWhenFacingEast
test14_MovesTheRobotForward1SpaceInTheDirectionItIsPointingDecreasesTheXCoordinateByOneWhenFacingWest
test15_WhereRTurnRightLTurnLeftAndAAdvanceTheRobotCanFollowASeriesOfInstructionsAndEndUpWithTheCorrectPositionAndDirectionInstructionsToMoveEastAndNorthFromREADME
test16_WhereRTurnRightLTurnLeftAndAAdvanceTheRobotCanFollowASeriesOfInstructionsAndEndUpWithTheCorrectPositionAndDirectionInstructionsToMoveWestAndNorth
test17_WhereRTurnRightLTurnLeftAndAAdvanceTheRobotCanFollowASeriesOfInstructionsAndEndUpWithTheCorrectPositionAndDirectionInstructionsToMoveWestAndSouth
test18_WhereRTurnRightLTurnLeftAndAAdvanceTheRobotCanFollowASeriesOfInstructionsAndEndUpWithTheCorrectPositionAndDirectionInstructionsToMoveEastAndNorth
which is a bit awful to ask a GUI IDE to deal with.
The canonical schema specifies both "description" and "comments". One of those is implicitly longer, and the other needs to provide a minimal identifier for the test. What other data is available to generate unit test method names of reasonable length?
btw, How are method names generated for other languages?
I didn't spend the time making this edit to shorten the descriptions only for the sake of making them shorter. Its about distinguishing a descriptive-identifier from a verbose-comment.
I'd previously suggested in #1473 adding a separate field for this, but the preferred path given to me was shortening the "description" field. I'd be interested in review from @rpottsoh @ErikSchierboom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single word or 3 word descriptions. You lose a lot of information in the test suite this way.
That is what comments are for.
But I appreciate that there is a random sampling of approaches among language tracks, and curious on the details of how "comments" are handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which is a bit awful to ask a GUI IDE to deal with.
Oof. I can imagine. That looks like quite a bit 😓. Since the names are pretty descriptive in their original form, would this work by not cascading them?
and curious on the details of how "comments" are handled.
Comments are for the generator / implementer, free form and no rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are method names generated for other languages?
#1411 has some info on that. To add to it: If we look at Python, Go and C# implementations of this exercise, only C# uses the description for method naming. Perhaps you could take a look at Go or Python for other options.
In the WIP Julia generator I'm working on the description is added as a comment and the comment is discarded but the idea of naming (or describing) every single test is not a thing in the language anyway.
That is what comments are for.
That's what the description is for. From the README:
Keep in mind that the description should not simply explain what each case is (that is redundant information) but also why each case is there. For example, what kinds of implementation mistakes might this case help us find?
I don't actually think there was anything wrong with any of these descriptions.
I do think they don't do a great job of explaining the why but these changes don't help with that issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think they don't do a great job of explaining the why but these changes don't help with that issue.
Right. What I meant that I didn't think the length was problematic as is ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Python & Go don't use directly use the description, my changes will have no impact on them. Can you provide some concrete code examples of where my changes cause harm?
Reviewing Python robot_simulator_test.py
and Go robot_simulator_test.go robot_simulator_step2_test.go & robot_simulator_step3_test.go
their method names look like they aren't generated and so don't directly depend on the descriptions. So I don't understand what "other options" I can infer from them.
Reviewing C#, it looks like their method names are generated similar to Pharo by concatenating each level's description. Their longest is an 190 character identifier. This change may be beneficial to them? @robkeim @GKotfis @ErikSchierboom @abecerramatias
public void A_robot_is_created_with_a_position_and_a_direction_robots_are_created_with_a_position_and_direction()
public void A_robot_is_created_with_a_position_and_a_direction_negative_positions_are_allowed()
public void Rotates_the_robots_direction_90_degrees_clockwise_changes_the_direction_from_north_to_east()
public void Rotates_the_robots_direction_90_degrees_clockwise_changes_the_direction_from_east_to_south()
public void Rotates_the_robots_direction_90_degrees_clockwise_changes_the_direction_from_south_to_west()
public void Rotates_the_robots_direction_90_degrees_clockwise_changes_the_direction_from_west_to_north()
public void Rotates_the_robots_direction_90_degrees_counter_clockwise_changes_the_direction_from_north_to_west()
public void Rotates_the_robots_direction_90_degrees_counter_clockwise_changes_the_direction_from_west_to_south()
public void Rotates_the_robots_direction_90_degrees_counter_clockwise_changes_the_direction_from_south_to_east()
public void Rotates_the_robots_direction_90_degrees_counter_clockwise_changes_the_direction_from_east_to_north()
public void Moves_the_robot_forward_1_space_in_the_direction_it_is_pointing_increases_the_y_coordinate_one_when_facing_north()
public void Moves_the_robot_forward_1_space_in_the_direction_it_is_pointing_decreases_the_y_coordinate_by_one_when_facing_south()
public void Moves_the_robot_forward_1_space_in_the_direction_it_is_pointing_increases_the_x_coordinate_by_one_when_facing_east()
public void Moves_the_robot_forward_1_space_in_the_direction_it_is_pointing_decreases_the_x_coordinate_by_one_when_facing_west()
public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_series_of_instructions_and_end_up_with_the_correct_position_and_direction_instructions_to_move_east_and_north_from_readme()
public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_series_of_instructions_and_end_up_with_the_correct_position_and_direction_instructions_to_move_west_and_north()
public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_series_of_instructions_and_end_up_with_the_correct_position_and_direction_instructions_to_move_west_and_south()
public void Where_r_turn_right_l_turn_left_and_a_advance_the_robot_can_follow_a_series_of_instructions_and_end_up_with_the_correct_position_and_direction_instructions_to_move_east_and_north()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide some concrete code examples of where my changes cause harm?
At least in the current form of the schema, it uses the description for something it's not intended to be, thus making the file less human-readable and more annoying to generate for generators that rely on the description being descriptive. I gave examples for both these points above.
So I don't understand what "other options" I can infer from them.
Ways to generate test suites without using the descriptions as method names directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least in the current form of the schema, it uses the description for something it's not intended to be, thus making the file less human-readable and more annoying to generate for generators that rely on the description being descriptive.
@SaschaMann Please note, I'd prefer not to change these descriptions at all. I'm only doing so as I was directed to here.
@@ -31,7 +33,8 @@ | |||
} | |||
}, | |||
{ | |||
"description": "Negative positions are allowed", | |||
"description": "Allows negative positions", | |||
"comments": [ "Negative positions allowed" ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment just repeats what the description says, so it could be removed. Same with the comments in L58, L62, L82 etc.
(I'm opposed to the suggested changes in general (see the other comment thread), but if this would go through, the redundancy should be removed imo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the comment is superfluous here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the same when I did it. I was just trying to not to lose any info. I'll wait to see how the other discussion pans out be doing such cleanup.
I agree here. Yes the names are long, but I'm not in favor of shortening them and move the actual details to the comments to be honest. I'm not opposed to seeing if we can get away with shortening the names without losing any information, but to me these changes are bit much. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that if there is a middle way where the description contains the same quality but is shorter for the benefit of test generators that create identifiers from the description (even if this is only the Pharo track for now), but not so short that they become indecipherable, nobody stands to lose.
Here are some ideas.
As for the "comments": ...
, most of the ones that were added seem superfluous and can be removed.
It would only make sense to add a comment if it contains anything of value for track maintainers. So, for example, a comment that adds "from the README" does not warrant the addition of a comment, I think. As a track maintainer, this doesn't help me do anything.
As for the way the Pharo track generates test case identifiers: It seems that it concatenates the outer description and the inner description. Are there examples of canonical data for some exercises where the inner descriptions themselves don't make any sense without this concatenation?
I suppose that any kind of consistency between the relationship between an outer and an inner description will make it easier to generate names based on them. Do you have any input here wrt. path of least resistance, @bencoman?
@@ -10,10 +10,12 @@ | |||
], | |||
"cases": [ | |||
{ | |||
"description": "A robot is created with a position and a direction", | |||
"description": "Creation", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Creation", | |
"description": "Create robot with position and direction", |
@@ -31,7 +33,8 @@ | |||
} | |||
}, | |||
{ | |||
"description": "Negative positions are allowed", | |||
"description": "Allows negative positions", | |||
"comments": [ "Negative positions allowed" ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the comment is superfluous here.
@@ -51,10 +54,12 @@ | |||
] | |||
}, | |||
{ | |||
"description": "rotates the robot's direction 90 degrees clockwise", | |||
"description": "Rotate clockwise", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Rotate clockwise", | |
"description": "Rotate 90 degrees clockwise", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to rotate other than 90 degrees? If not, it is superfluous to say so.
Maybe "Turn clockwise" would be better.
"cases": [ | ||
{ | ||
"description": "changes the direction from north to east", | ||
"description": "north to east", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "north to east", | |
"description": "Change direction from north to east", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already know it changes direction, since the parent is "Rotate clockwise"
For a succinct unit test identifier, I feel the [1.] below doesn't lose any information
over @sshine suggestion [2.] and original [3.]
1. rotate_clockwise_north_to_east
2. rotate_90_degrees_clockwise_change_direction_from_north_to_east
3. rotates_the_robot's_direction_90_degrees_clockwise_changes_the_direction_from_north_to_east
@@ -73,7 +78,8 @@ | |||
} | |||
}, | |||
{ | |||
"description": "changes the direction from east to south", | |||
"description": "east to south", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "east to south", | |
"description": "Change direction from east to south", |
"cases": [ | ||
{ | ||
"description": "increases the y coordinate one when facing north", | ||
"description": "facing north", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "facing north", | |
"description": "Move forward facing north increases y coordinate", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats the same length as the original, which is pointless for me. The goal is facilitate reasonable length unit test names. And we already know its moving forward from the parent
@@ -235,7 +250,8 @@ | |||
} | |||
}, | |||
{ | |||
"description": "decreases the y coordinate by one when facing south", | |||
"description": "facing south", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "facing south", | |
"description": "Move forward facing south decreases y coordinate", |
@@ -254,7 +270,8 @@ | |||
} | |||
}, | |||
{ | |||
"description": "increases the x coordinate by one when facing east", | |||
"description": "facing east", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "facing east", | |
"description": "Move forward facing east increases x coordinate", |
@@ -273,7 +290,8 @@ | |||
} | |||
}, | |||
{ | |||
"description": "decreases the x coordinate by one when facing west", | |||
"description": "facing west", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "facing west", | |
"description": "Move forward facing west decreases x coordinate", |
@@ -294,10 +312,14 @@ | |||
] | |||
}, | |||
{ | |||
"description": "Where R = Turn Right, L = Turn Left and A = Advance, the robot can follow a series of instructions and end up with the correct position and direction", | |||
"description": "Series of instructions", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Series of instructions", | |
"description": "Follow Left, Right and Advance instructions", |
This seems like a fine movement from description to comment.
This means that this comment most likely does not end up with the user.
Comments are meant for track maintainers / test generator writers.
So maybe this means that a cryptic part of an exercise becomes more cryptic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any other instructions beside Left, Right, Advance? Otherwise its redundant to mention them.
Quite a bunch in the C# track: https://github.com/exercism/csharp/search?q=TestMethodNameWithPath&unscoped_q=TestMethodNameWithPath (look for |
Taking a step back for a moment. What we are coming against here is having a single field serving two purposes...
then ending up serving neither purpose well. The alternative is to have a separate field for each purpose per. Support #1473 and the need for this and subsequent PRs vanishes. I am somewhat dreading getting all of us bogged down in similar discussion for other exercises. But will have to keep pushing. Some of the generated names are truly awful. |
I see Scala concatenates nested descriptions into a comment. I think that works well as a comment, not so well as an identifier. The code panes of IDEs are typically much wider than the navigation panes. And the way PHP nests descriptions as comments looks fine, but individual tests are annoymous, whereas other languages finely distinguish each test condition by name (at least Pharo and CSharp). |
@bencoman I think your concerns are valid, raising fruitful discussion and we can clean-up a lot of these, but we just got to consider what it means for all the generators that already exist -- and that it can be a series of changes both in how your generator works and how ours work 👍 |
@SleeplessByte thanks for your support. Just to clarify... my concern is nothing about these descriptions "as descriptions". I wouldn't want to change them except that they make poor identifiers. |
@sshine Its the highly subjective nature of "same quality but shorter" that I'm concerned will burn everyone's time bike-shedding over. I don't really want to be corrupting descriptions to produce better identifiers. They serve different purposes and jamming both into one field compromises both. I'm coming more to believe its better to separate the concern for an "identifier" to a separate optional field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to properly bump the version at some point if this is to be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
@SaschaMann You are listed as a pending reviewer. Could you perhaps take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perfect @bencoman. Thanks for keeping with us.
@ErikSchierboom check slack dm.
Thanks @bencoman! It really is appreciated. |
I've just submitted a PR for the C# track and the new descriptions are a huge improvement: exercism/csharp#1287 |
Comparing the current tests (3.1.0.7) with the current canonical version for this exercise (3.2.0), the descriptions and titles have changed in the PR exercism/problem-specifications#1525
Comparing the current tests (3.1.0.7) with the current canonical version for this exercise (3.2.0), the descriptions and titles have changed in the PR exercism/problem-specifications#1525
[Edit] Some language tracks (e.g. Pharo) individually identify tests. To auto-create these identifiers during code generation, the only data currently available is the canonical data "description" field. Some tracks insert this field directly into their generated code as a comment, and the "descriptions" are suitably verbose for that purpose. However such verbosity generates some very long identifiers (e.g. >150 characters).
Issue #1473 proposed to adding a distinct "identifier" field. Back-pressure there directed me to first try compressing "descriptions" to suit "identifier" generation. This PR is a trial at doing that - minimizing description length without losing information. However even if no substantive information is lost, I such compression may compromise the readability of comments generated from the "descriptions", so I'm interested in feedback on that here and in #1473.
P.S. When originally creating this PR I misunderstood the canonical data "comments" field was for maintainers only and unrelated to generated comments for students. Original text of this post...