-
-
Notifications
You must be signed in to change notification settings - Fork 525
Change Minimal Solution for Acronym #943
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
Comments
I have a lot of fun mentoring this exercise and have done it lots. Some thoughts:
All of this makes me a big fan of this exercise - it's possibly my favourite to mentor - and I'd be sad to see it changed or watered down. However, your points are much more important than mine. If core#3 needs to teach cool ruby methods, is this the wrong exercise to do it? The optimal solution to core#3 should be something consisting of lots of chained cool ruby methods, which the optimal solution to this isn't. Saying that, I'm not entirely against guiding someone to the solution you pasted. But I think if we do do that, I'd like to have a rule that we generally give people a "Bonus test" at the end, which has a few more chars that aren't There's a general point here as well, that there isn't an absolute optimal/guidance solution here. There's a different optimal one depending on the starting point. One great use of the Automated Mentoring Support Project might be to take a solution to Acronym and say to the mentor "This is the target solution for this student". So if they start with |
I agree that the purpose of Ruby track is to learn Ruby. And regular expressions are part of it. What I would change though is to encourage developers to think about diversity of the world we're living in, so I would add a couple of tests for Unicode (maybe German with diacritics and Russian, leaving Arabic and Hebrew aside 😄) and change the minimal solution to |
I would probably think about that diversity in a later exercise, and one that is focused on encoding, perhaps more than Regexp. Or to give as a challenge if it appears that the student is up for it in discussions. |
Both good points. I think that teaching how to use Regexps in Ruby is important. I think teaching the details of regexpes themselves is not in scope - that doesn't mean we don't do it as a bonus thing, but it's not part of what we must do. So I think teaching |
I hate, hate, hate this solution and always try and steer students away from it. Most are super impressed when they see the simplicity of what can be done with JUST I find negative filtering (dealing with characters like "-" on a one off basis) is also a far more fragile programming practice that scanning for a positive match. If you need a-z, just scan a-z, don't try and filter out all the junk, because there is a lot of junk out there - you'll be updating your code every day in the real world, etc... I think that's an important lesson that this exercise gives an opportunity to teach. Update: Almost none start with tr/split though... all the students (IIRC) are already using regex to being with, just not an optimized regex... and only they are trying to splitting on a regex vs scanning. |
I agree with @yyyc514, but perhaps not as strongly 😄 I prefer to phrase the code positively. I also agree that we might be over-emphasizing regular expressions. |
That for sure might be true on some exercises, but I don't think this one. It sure would be nice if the exercises could give students one or two small hints though. Like a hint or link to "word boundaries" would help so many students get this right the first time around I think. The only thing simpler than I mean I supposed you have to understand the concept of grouping/meta-characters, etc... but students almost always know that already... they are trying to use \w in a 100 zany ways to solve this. The only piece of the puzzle that are missing is \b (at least in my experience). |
Here are my thoughts: I love the idea of focusing on the things you want vs. focusing on the things you want to exclude. Recently I've had a few students coming from other tracks ask me if In my experience, changing the For this reason when students wonder outside the provided test cases I end up suggesting that a I wonder if we should have something on the mentor notes talking about this. Something pointing out that while this solution is great for the tests that we have on the Ruby track it gets complicated very fast when you introduce all the test cases described on the problem specifications repo. Does anyone know of an elegant Regex we can suggest for So, that's my main gripe with the minimal solution we propose now - it's an excellent improvement if you only consider the tests we have but it falls apart when you start thinking about some not-that-uncommon edge cases, which some more advanced students end up doing. PS: personally I don't care too much about the use of a regular expression this early in the track, but I understand if it is off-putting for some students. |
Just quickly. Might be better approach. But you're right that the exercise would get much more complex if we included such examples.
Definitely more of a challenge. And starting to feel like the point where just splitting into "word units" and then analyzing them with regex might be a better approach for most students. I'm all for added these more complex things to the tests though, and if that means finding a better proposed solution then so be it. |
That's great, thank you ❤️ Didn't think of using This gives me a bit more maneuverability next time someone asks about that test. For the second one, the mentor notes have this: Learned a few things by studying that one... Namely the negative lookbehind assertion |
Is that negative lookahead or non-capture or what? I get lost at this point, lol. Does anyone have a clue if students actually go thru the tests one at a time removing |
Negative lookbehind, yep. Had no idea this existed 😄
|
Ah, yeah forgot about negative look-BEHIND. LOL. Regex is ridiculous. |
Some final points:
|
Or what about optional tests? A few of the other exercise have "This test is hard, you don't have to make it pass necessarily." Maybe something like extra credit? |
That's also a nice option IMO 👍 Updating the mentor notes would be even more relevant in that case, I think, since a lot more people will be thinking about these cases. |
So I totally agree that Aconym has excellent options to make it more interesting. It's def something to take into consideration - for the future. At the moment, though, :
Also, it's not about not having regex in the track, it is about the best exercise at the best position. So. Given the current test suite and the current position of Acronym in the track, may I rephrase my question:
|
At least |
As a note to mentor, I would like to have the transition explicitly commented if it is early in the track of "Why" the |
Like we currently have in the Series notes:
|
But if I understand correctly, there's no worrying about extra objects that are created, or whatever Ruby things I may not be aware of? |
I feel like this point got overlooked slightly :) I'm strongly against guiding someone to a suboptimal solution if they're perfectly capable of guiding them to an optimal solution*. So if we do end up changing the mentor notes for this (which I think is what we're discussing really here, rather than discussing changing the exercise - and I wonder if therefore this would have been better in So, while it's not necessarily ideal, I would argue that it would be better to design an exercise specifically to chain the actual methods you (Maud) feel we should teach at this stage, than try to shoehorn this one in. Adding this as a side-exercise hanging off that new exercise could work nicely. Which, with reference to your comment of "showing the strength of Ruby's built in methods, and showing that Ruby has a lot of convenience methods for common operations." leads me to ask the question of "What are we actually trying to demonstrate to the student here". Or to use Track Anatomy speak, what axes is this exercise on on the progression lines? (* I'm defining "optimal" as how I would do it :)) |
Hmmm, yeah. Okay, I'll leave it. |
Currently, the Minimal Solution for Approval for Acronym as advertised in the Mentor Notes is:
fullname.scan(/\b[a-zA-Z]/).join.upcase
in favour of solutions that use
split
.As different people has pointed out, this solution is not ideal.
I know the Mentor Notes state that the exercise is meant to introduce
scan
- I wrote that myself - but the reason behind it was rather: showing the strength of Ruby's built in methods, and showing that Ruby has a lot of convenience methods for common operations. That's supercool, butscan
is not the best showcase in this regard.So, with the new insights, I'm looking for a candidate to replace the scan solution.
This is my favorite so far:
fullname.tr('-', ' ').split.map {|word| word.chr}.join.upcase
It's a much better show case for Ruby's specialty methods, with
tr
forgsub
andchr
forArray#[]
And no need for a regex, yay!(And in case you wonder: it's faster than the
scan
solution. )OTOH I'd rather introduce Symbol#to_proc later, but it may be hard to resist the temptation to show
map(&:chr)
for us while mentoring.Recap:
scan
solutionscan
solution?The text was updated successfully, but these errors were encountered: