-
-
Notifications
You must be signed in to change notification settings - Fork 553
Add split-second-stopwatch
exercise
#2547
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
Conversation
CC @exercism/reviewers |
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've reviewed the instructions and intro as thoroughly as I could. Here are the changes I believe would improve clarity and flow. Hopefully, I haven't overlooked anything. Of course, there's some subjectivity involved, so feel free to adjust and incorporate whatever you find appropriate.
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
|
||
- Start: start/resume time tracking | ||
- Stop: stop (pause) time tracking | ||
- Current lap: the time tracked for the current lap |
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.
- Current lap: the time tracked for the current lap | |
- Current lap: display the time tracked for the current lap |
The other list items use a verb to indicate what we're doing with the tracked time.
- Start: start/resume time tracking | ||
- Stop: stop (pause) time tracking | ||
- Current lap: the time tracked for the current lap | ||
- Previous laps: the times of all previously recorded laps |
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.
- Previous laps: the times of all previously recorded laps | |
- Previous laps: display the times of all previously recorded laps |
The other list items use a verb to indicate what we're doing with the tracked time.
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.
Also is this the running total or all the individual lap times?
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.
"display" implies "STDOUT" to me, which isn't used in most tracks/exercises.
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.
Track the time then?
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.
Track could work. What would your preference be Isaac? BTW I agree with Isaac's sentiment
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.
Retrieve the previously recorded lap times? I'm not sure if "track" would imply an implementation detail.
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 also had a lot of trouble with current lap and previous laps when I initially reviewed. I intentionally left out the verbs because I wasn't sure what an appropriate verb would be. I intended to ask a question but completely forgot about it before posting the review.
- Current lap: the time tracked for the current lap | ||
- Previous laps: the times of all previously recorded laps | ||
- Reset: stop time tracking, reset the current lap, and clear all previously recorded laps | ||
- Lap: add the current lap time to the previous laps and start a new lap |
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 line is unclear. Are we adding the lap time to a running total or keeping a history of the previous laps?
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.
Well, sort of both. Lap does not influence the total running time, it's just a cutoff point where the current lap time is basically "stopped", then added to the previous laps and then the current lap time is reset in order to start counting from zero again
- Start: start/resume time tracking | ||
- Stop: stop (pause) time tracking | ||
- Current lap: the time tracked for the current lap | ||
- Previous laps: the times of all previously recorded laps |
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.
"display" implies "STDOUT" to me, which isn't used in most tracks/exercises.
FWIW I wrote a simple semi-flexible tester that reads the tests from the JSON file and tests the implementation, in Python. |
I've tweaked a bit. |
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
@@ -0,0 +1,194 @@ | |||
{ | |||
"exercise": "split-second-stopwatch", | |||
"comments": ["Times are formatted as 'HH:mm:ss'."], |
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 may not be clear in terms of "What do these letters mean". I mean to say that it may be intuitive that it is hour, minutes, seconds, but why the change in case for hours?
It can be useful to show a time where the HH
is put in place, such as 13:14:15, to show the difference from a 12 hour clock to a twenty four hour clock. To others, it will be clear, but via experience rather than inherent knowledge.
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.
Fair point! I'll update
{ | ||
"command": "lap" | ||
}, | ||
, |
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.
, |
jq
says invalid JSON.
}, | ||
{ | ||
"command": "currentLap", | ||
"expected": ["00:00:00"] |
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.
Prior currentLap
commands expect a string. This and the next expect a list.
Same for total
below.
"command": "stop" | ||
}, | ||
{ | ||
"command": "lap" |
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.
error: cannot lap a stopwatch that is not running
The tests suggest after calling stop
the state is ready
. The last test says lap
cannot be called from a ready state. 7 other tests call stop
(putting it into a ready state) then lap
.
Yeah, I'm still working on the canonical data. I'll fix it. |
I've updated and streamlined the canonical data as well as adding more test cases. |
This data works with my implementation.
|
This is now ready for another round of reviews |
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com>
@BNAndras could you maybe also check the latest version? |
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.
Approving with one small potential tweak.
Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com>
This PR is intended as a starting point for a discussion on adding a new practice exercise.
The exercise's goal is to have students work with time, as well as deal with a sort of state machine.
The things I'd like to discuss are:
circular-buffer
)I've done a basic implementation of the exercise in C#: exercism/csharp#2403