Skip to content
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

[Sept Sprint] New exercise teaching type-conversion #1645

Closed
3 tasks done
ErikSchierboom opened this issue Sep 17, 2021 · 9 comments
Closed
3 tasks done

[Sept Sprint] New exercise teaching type-conversion #1645

ErikSchierboom opened this issue Sep 17, 2021 · 9 comments
Assignees

Comments

@ErikSchierboom
Copy link
Member

ErikSchierboom commented Sep 17, 2021

This is part of our September Spring to get the Go Track in shape. Please read the Overview issue for more details. This exercise is claimed by @jmrunkle.


Before building this exercise (or exercises), please read up on the documentation.

We need an exercise for the type-casting and type-assertions concepts. Since there is sometimes confusion around those two things, it makes sense to teach both in the same exercise to demonstrate how they are related.

If it makes sense, this exercise could also teach about the type-switch concept.

The exercise should teach:

  • How to convert from one type to another
  • How to assert a type
  • How to assert an interface type

This exercise will have at least interfaces as a prerequisite.


Remaining work:

@ErikSchierboom
Copy link
Member Author

@jmrunkle
Copy link
Contributor

This is blocked on #1638. Until then we cannot add an exercise that requires the interfaces concept. We can add it as status: "wip", but configlet will complain if you try to enable the new concept exercise since its prereq is not taught by some exercise.

@jmrunkle
Copy link
Contributor

I would be happy to take this one, but I am having trouble coming up with a good story for this one. I looked at the canonical stories list (https://exercism.org/docs/building/tracks/stories), but nothing jumped out at me.

The best I could come up with is you have some kind of sorting room which has to handle anything that is put in there. Some things have predefined results (eg. "This is a number" or "This is a string"), but a few things need to be unpacked and have their contents inspected (eg. "This is a box containing a number 4"). Anything unexpected will be marked "Return to sender".

If no one has a better story I can get rolling with that.

I'll probably start with a PR just to fix the actual concept documentation for type-conversion and type-assertion which is nothing but TODOs right now. I can also add the type-switch concept which seems pretty relevant here.

@jmrunkle jmrunkle self-assigned this Sep 27, 2021
@jmrunkle jmrunkle changed the title [Sept Sprint] New exercise teaching type-casting [Sept Sprint] New exercise teaching type-conversion Sep 28, 2021
@ErikSchierboom
Copy link
Member Author

I think that story could work fine. Maybe you could make it Santa themed and have the boxes be presents or something like that?

@jmrunkle
Copy link
Contributor

I was already pretty far into the implementation by the time I saw your comment there Erik so I am probably just moving forward with the sorting room idea rather than trying to refactor it to be about Santa. For the record, here is what the intro looks like so far:


Jen is working in the sorting room in a large factory. The sorting room needs to process anything that comes into it by categorizing it with a label. She needs a program to help her with the sorting.

Most primitive values should get straight-forward labels. For numbers, she wants strings saying "This is the number 2.0" (if the number was 2). Jen wants the same output for integers and floats. For booleans, she wants strings saying "This is false" or "This is true".

There are a few Box interfaces that need to be unwrapped to get their contents. For a NumberBox, she wants strings saying "This is a box containing the number 3.0" (if the Number() method returns 3). For a BooleanBox, she wants strings saying "This box is true" or "This box is false" (depending on the result from the Boolean() method).

Anything unexpected should say "Return to sender" so Jen can send them back where they came from.


Seems to work well enough and gives me enough space to get the ideas across. I am sure there will be more discussion over in the pull request itself.

@junedev
Copy link
Member

junedev commented Sep 28, 2021

tbh I think a neutral theme is better than something related to a christian holiday that does not exist in some cultures

@ErikSchierboom
Copy link
Member Author

True. The sorting room is perfectly fine.

@jmrunkle
Copy link
Contributor

Woot, got that one out the door!

@ErikSchierboom
Copy link
Member Author

Sweet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants