can I do something like this with Double Dispatch
Hello, Just thinking how to solve the bowling challenge from exercism. but I wonder if I can do something like this in the method that checks if I have the right object I was thinking about this : Result -- Strike -- Spare -- allOther then In Strike something like this checkForBonus: number1 score2: number2  ^ number1 + number2 == 10 or am I thinking the totally wrong way to solve this? Roelof
Remember, we cannot see the Smalltalk exercises in exercism. We cannot help you without knowing what problem you are trying to solve. Is this problem basically the same as https://www.reddit.com/r/dailyprogrammer/comments/3ntsni/20151007_challenge_... or is it different? Double dispatch is a programming technique, not an end in itself. A weird thing about the exercism site is that you can see *solutions* to problems for a language even if you cannot see the *problems* themselves. So I have seen *solutions* to Bowling in several languages; some with no objects at all, and some using single dispatch only. This is a 'medium' problem, meaning the solution is maybe 2 or 3 pages. KEEP IT SIMPLE. Not every *concept* needs to be a *class*. On Sat, 6 Apr 2019 at 21:53, Roelof Wobben <r.wobben@home.nl> wrote:
Hello,
Just thinking how to solve the bowling challenge from exercism.
but I wonder if I can do something like this in the method that checks if I have the right object
I was thinking about this :
Result -- Strike -- Spare -- allOther
then In Strike something like this
checkForBonus: number1 score2: number2 ^ number1 + number2 == 10
or am I thinking the totally wrong way to solve this?
Roelof
participants (2)
-
Richard O'Keefe -
Roelof Wobben