Ruby: Debugging Lesson: replace `pry` with `binding.irb` in ruby debugging lesson
Because
This PR is partially addressing #24994
The eventual goal is to have two lessons here. One that introduces more basic debugging concepts (reading stack trace and errors, print statement debugging, etc.) and another lesson that sets learners up with the more interactive debugging tools. This lesson is being converted to one that just reveals some of the more basic concepts, meaning that references to pry have been removed. In its place, I've included information about binding.irb, which I think is a good primer for interactive debugging while holding off a bit on the complexities of stepping through code.
This PR
- Removes references to
pry. - Adds a section for using
binding.irb
Issue
Related to #24994
Additional Information
I've made this a draft PR because I expect to iterate on this some. There are a couple of things that I think are worth discussing:
- Should the debugging exercise assignment still be placed here? Or should it perhaps be moved to the lesson that will follow this one? This might also be an opportunity to rethink the debugging exercises (see the Issue for some thoughts on this).
- I didn't touch any
p/putsstuff, but I feel like some of it could be improved. It currently only mentionsnilas a potential problem for usingputsoverp, but there are a couple of other pretty significant distinctions to be made I think:-
preturns its arguments, whereasputsreturnsnil. This makespnice for reducing any thought or regard for how what you're adding to the code is affecting the way it functions. -
preveals a more "code"-like representation of objects. This is of course the reason behind thenilthing, but I'd say the impacts of this go beyond justnil.
-
- The section for "How to Start Debugging" feels pretty slight. I think it could be a good idea to add more. It might also be a good idea to move it to the next lesson when all of the tools will have been introduced.
- I had to scrub most of the readings in the Assignment section because they were
pryfocused. I'd definitely be interested in finding other outside resources that focus on the tools in this updated lesson. Unfortunately, I wasn't able to find any good articles onbinding.irb. I definitely welcome any additional resources people know of or can find that coverpdebugging orbinding.irb.
Pull Request Requirements
- [x] I have thoroughly read and understand The Odin Project Contributing Guide
- [x] The title of this PR follows the
location of change: brief description of changeformat, e.g.Intro to HTML and CSS lesson: Fix link text - [x] The
Becausesection summarizes the reason for this PR - [x] The
This PRsection has a bullet point list describing the changes in this PR - [x] If this PR addresses an open issue, it is linked in the
Issuesection - [x] If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
- [x] If any lesson files are included in this PR, they follow the Layout Style Guide
Thanks @JoshDevHub , will aim to review in the next 48 hours - feel free to ping me if I slack :chicken:
@ChargrilledChook You're slacking! :chicken:
I don't actually mind, but I figured with it being the weekend, you may have some time to give it a look. So I thought I'd shoot you a reminder.
Closes #25914
@ChargrilledChook I can absolutely still work on this. I'll fix the capitalization and look into those other ideas. Glad to see this all coming along :muscle:
Regarding the positioning in the course, I think this specific lesson could jump earlier in the basics. Maybe directly after 'Loops' could be a good candidate?
@ChargrilledChook Apologies for taking a while on this. I did want to add more for puts/p. I've sat down a couple of times to write some content, but it always felt messy and inelegant. Then I remembered your "mini-cheatsheet" idea, which honestly sounds like an excellent way to quickly communicate the difference.
Do you have any ideas about how to approach that kind of thing though? Tables didn't feel quite right to me from experimenting in the Lesson Preview tool (small example here). Was wondering if you had an idea in mind for it.
I have nothing to do with this PR, but I just wanted to add some notes here:
- since
binding.irbopens an IRB session, it is possible to mutate state (and execute any arbitrary code) in the local context. I don't think was talked about in the changes made in this draft, but I think it should (as both a warning and a feature) - Might be worth mentioning another way to use irb to probe/debug: Start an irb session in project directory, then
require_relativetheproject_file.rbso that the irb session has access to all of the code inproject_file.rb(also works with internalbinding.irbs ) -- useful for testing out an interface without having to modify a driver script below the class definition - Learners will likely already be familiar with break-points and step into/out of/over from the Foundations course. It might be worth it to mention that this will be (is supposed to be) covered in a later lesson
- corresponding mentions of pry in the exercises repo: lines 46 to 49 in the exercise file and line 41 in the spec
Love to see this additional section being added. Slightly related. Here's an additional resource that helped me immensely in understanding how binding.pry works. https://github.com/radanskoric/ruby_debug_tutorial
I think knowing about both and understanding how they are different will help students when to use what. Any way we can combine the two?