problem-specifications
problem-specifications copied to clipboard
date-duration arithmetic exercise
In the Go track the birthday thing was super distracting. I've removed it in https://github.com/exercism/xgo/pull/222
Have you noticed anything in your respective tracks? It seems like it might work in some languages and not others. /shrug.
We were talking about Gigasecond at my Kata group today. None of us particularly liked it because the tests didn't ever show off any interesting behavior. It seemed like once you got one test passing, all of them would pass. Then, if your language supports it, you could add your birthday. But your birthday isn't a weird edge case, or anything special. It's just another date.
Instead we were wondering if the Gigasecond could be expanded into a more interesting look at API design. In Ruby, at least, we liked writing methods like 1.gigaseconds_since(Time.now), or (2.3).gigaseconds_before(Date.yesterday). Other languages probably also offer ways to write interesting methods for date manipulation.
In Go there are some really nice lessons about the standard library, the difference between constants and variables (significant in some ways in Go), about time.Duration, type conversions, support for scientific notation, etc.
In languages where it doesn't add anything interesting in terms of ramping up in the language or in understanding some core programming concept it should either be transformed into something more interesting, or just deprecated/foregone.
I think the idea of exploring activesupport style monkeypatching/api design could be an interesting take on the problem.
I think it's helpful for a new programmer or someone new to a language to figure out how dates are supported, or as a challenge to implement a simple date representation. I sense some untapped pedagogical potential though.
Gigasecond is a duration, a more advanced exercise, could be to exercise or implement date-duration arithmetic in the language:
date - date = duration
date +/- duration = date
duration +/- duration = duration
date + date = error
duration +/- date = error
Duration arithmetic is a very interesting extension. I don't know if it would be as part of this exercise or a separate one. Go already has duration implemented as part of the standard library, so this exercise works as a discovery tool for how durations work. In languages where there is no such thing, it would probably turn this into a more advanced exercise.
Is it reasonable to mix the two and write a README that would leave both options open, or would it be better to separate them and then have each language track choose which of the two exercises (one or both) are appropriate to the language?
Though it's true that neither #36 nor the current JSON at https://github.com/exercism/x-common/blob/master/exercises/gigasecond/canonical-data.json have birthday in the set of tests, there is acknowledgment of it in the comment. I think that's as good as it's going to get here, and letting individual tracks decide whether to have it.
The date-duration arithmetic discussion qualifies as a new exercise idea and that is the unresolved part of this issue, so I'll label it to suit.
As (very) we're short on date/time exercises, it would be great if we could create a new exercise to focus on these concepts. Something like being passed to datetimes and having to return a description of the duration between them (e.g. "2 days ago", "3 weeks ago", etc.) could maybe work here.