On Sun, Aug 30, 2020 at 10:04 PM Roelof Wobben via Pharo-users < pharo-users@lists.pharo.org> wrote:
Hello,
I have this challenge from exercism : https://github.com/exercism/pharo-smalltalk/tree/master/exercises/clock
and this function is given :
hour: anInteger minute: anInteger2 self shouldBeImplemented
Schould I make it on this class method work that the minutes will not exceed the 59 minutes So when for example when 70 min are given so hour:0 minute:70 it will be converted to hour: 1 minutes: 10
I would argue against that approach. Make it a requirement that a given API must be used with correct values. e.g. #hours:minutes: requires hours between 00 and 23 and minutes between 00 and 59. If you want to convert equivalent time values, use a specific API. For example, many time implementations publicly define a seconds-based API, such as Time class>>#fromSeconds:. You can do the same with your implementation with a class-side #fromMinutes: method. (The corresponding instance methods would be #asSeconds and #asMinutes or something similar.) or can I better do this on the instance side.
Regards,
Roelof