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

Concept Exercise: Strings #607

Closed
wants to merge 6 commits into from
Closed

Concept Exercise: Strings #607

wants to merge 6 commits into from

Conversation

pwadsworth
Copy link
Contributor

Adds Beers exercise for the String Concept per Issue #606.

Covers:

  • Insert unicode characters in strings
  • Use basic string functions (length, replace...)
  • Split and join strings (split, words, lines, (++), concat, join...)
  • Convert to and from other types (fromInt, toInt...)

@pwadsworth

This comment was marked as outdated.

Copy link
Contributor

@ceddlyburge ceddlyburge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Pete. Overall this looks like a fun exercise to solve, but the exemplar solution only uses String.replace, String.fromInt and ++, which seems like a small amount of string functions to be using in an exercise all about strings!
Maybe the squeaky clean exercise would be a better fit?

@@ -0,0 +1,46 @@
# Instructions

You are the new bosun of a small pirate crew that just killed their previous bosun for fowling their merriment with a bad song. As pirates would have it, your crew likes to pass the time getting loaded to the gunwales while crossing the briny deep and you are in charge of rationing the beer. The Cap'n has tasked you to minimize the number of resupply trips to make the best possible time between hauls. To achieve these conflicting requirements, and keep your crew from blowing you down when you are also loaded to the gunwales, you decide to stick to the tried-and-true 99 Bottles of Beer song using a program to help you keep the song straight and remind you to make a beer run when the ship is running low.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This in a very entertaining introduction to the exercise, and I thoroughly enjoyed reading it. I think it will probably make difficult reading for a non native english speaker though. Probably @mpizenberg and @jiegillet can comment on this, as they are non native english speakers.
Maybe we can find a way to keep the fun text but also make life easier for students. We can have a think, but maybe just a bit at the start stating that the following paragraph is not critical for the exercise.

> No more bottles of beer on the wall, no more bottles of beer.</br>
> Go to shore to get some more, 99 bottles of beer on the wall!</br>

## 2. Return the last two stanzas when starting with 1 beer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's generally smoother for the student if later exercises don't change the values of earlier ones, and that once a part of the exercise is successfully completed, the tests for that part pass.

I think that asking the student to refactor the existing function will break this pattern, and mean that the tests will fail even when part 1 is done successfully, so then the student doesn't know whether they have completed part 1 or not.

Maybe this can be avoided by creating a beerSongFrom0 in part 1, and a beerSongFrom1 here?

> 1 bottle of beer on the wall, 1 bottle of beer.</br>
> Take it down and pass it around, no more bottles of beer on the wall.<br><br>...

## 3. Return the last three stanzas when starting with 2 beers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here ...

> 1 bottle of beer on the wall, 1 bottle of beer.</br>
> Take it down and pass it around, no more bottles of beer on the wall.

Should be followed by either
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this changing of the final verse teach any string concepts? It looks like it is more about conditionals and scope ...

, skip <|
test "99 bottles" <|
\_ ->
beerSongFrom 99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is a need for the function to test the 99 case, it makes this file unnecessarily long! Maybe the >30 case as that is special ...

@ceddlyburge
Copy link
Contributor

Also, if we do use a different exercise for strings, we could still use this PR, by modifying it a bit and turning it in to the standard 99 bottles exercise

@pwadsworth
Copy link
Contributor Author

pwadsworth commented Sep 25, 2023

Hi Cedd, I was thinking in a similar way.: 99 Bottles as a second exercise for strings and Squeaky Clean as the primary.

That said, if 99 Bottles is not primary for Strings and doesnt block advancing on concepts, wouldn't it be better used to also practice/introduce refactoring? I was going for an approach similar to 99 Bottles of OOP (saw it on your blog and started reading it, and need to add the part I just got to this weekend 😁) driving the refactoring through the exercise steps.

If that's out of scope for the track, it is an easy change to make it a straightforward string replacement exercise. Let me know what you think.

@pwadsworth pwadsworth marked this pull request as draft September 26, 2023 01:51
@pwadsworth
Copy link
Contributor Author

Changing to Draft status until decision is made on whether to use or delete. Mention of alcohol not withstanding, I think this can be used for practicing/introducing "fearless refactoring." But, I understand it might be out of scope for the intent of the track.

@ceddlyburge
Copy link
Contributor

I think using this as a practive exercise is definitely a workable idea, but maybe we could park that for now. It is definitely better to have the tests for a task pass when the task is done, but I think that could be achieved by copy pasting each function to a new function before refactoring it. Also Green Bottles / 99 Bottles is a canonical exercise that already has its own tests and text and similar in the template repo, so we would probably want to make it clearly distinct from that. It's all doable though I think.

@jiegillet
Copy link
Contributor

Superseded by #611

@jiegillet jiegillet closed this Oct 15, 2023
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

Successfully merging this pull request may close these issues.

3 participants