-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Ruby: Debugging Lesson: replace pry
with binding.irb
in ruby debugging lesson
#25276
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
base: main
Are you sure you want to change the base?
Ruby: Debugging Lesson: replace pry
with binding.irb
in ruby debugging lesson
#25276
Conversation
Thanks @JoshDevHub , will aim to review in the next 48 hours - feel free to ping me if I slack 🐔 |
@ChargrilledChook You're slacking! 🐔 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff @JoshDevHub, I think this is most of the way there, I only have one typo nit.
Some things that I think we could (optionally) improve but are not required:
- It would be good to subtly introduce the concept of a breakpoint by showing an example of using binding.irb twice, and exiting to proceed to the next binding. Maybe even showing putting
binding.irb
inside a loop. We wouldn't even have to necessarily use the word "breakpoing" - It could be good to update the puts / p section slightly and put a bit more emphasis on using p for debugging. Maybe even something like an info box with a mini cheatsheet. Could even introduce
pp
too, potentially.
Outside of those minor details and ideas, my only concern is course structure. I think it might be worthwhile putting a bit of a gap inbetween this lesson and the rdbg lesson, otherwise we're introducing two tools without any real opportunity to show how rdbg builds on and improves irb.
But then where would it go? Unless it goes somewhere in the middle of the basic Ruby projects, it would get introduced in a spot just after it would have been really useful. Maybe directly after those projects is fine, but the current structure is a bit of an issue for things like this (ie big info dump with the basics section then 4 projects chained together).
An alternative would be to move this lesson earlier in the basic Ruby section.
In any case I'm probably rambling at this point, let me know your thoughts. I've made some decent progress on the rdbg basics lesson so if you have any capacity to work on this and get it ready for a release, that would be great ❤️ if not all good, but let me know
ruby/basic_ruby/debugging.md
Outdated
Thus, adding a `binding.pry` line in our code is similar to creating a breakpoint in JavaScript. | ||
|
||
To see this point in action, try running the following: | ||
You can add `binding.IRB` at multiple points in the execution of your program. To see this in action, try running the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental capitalisation here
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 💪 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? |
|
||
Using the same example above, you can use one of pry-byebug's commands to figure out what `name = name.upcase` will return. You won't need to quit the session or add another `binding.pry` beneath it. Enter `next` to step over to the next line. | ||
To proceed with the program, you can run the `exit` command, which will end the first IRB session and continue execution of the code. Because there's a 2nd `binding.irb`, it stops again. You can now see how `name` has changed and what `greeting` has been defined as. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding your 1st point about showing multiple binding.irb
, I already have this type of thing happening here, yeah? I definitely could change this example (or add a new one) that uses it inside of a loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep this is a great addition, I was thinking more a simple code example to illustrate. Not required, but I think a nice addition.
Hopefully people don't get stuck before reading on to the part on how to exit 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll say as a newby it took me a minute to figure out the exit command :). Perhaps in future updates, we can add something like "if you get stuck, sometimes it helps to read a bit past where you are! TOP builds on content, so you might have a question that we're just about to answer"
@ChargrilledChook Apologies for taking a while on this. I did want to add more for 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reviewing it, Thank you all for your contribution! I appreciate the effort you've put into this commit. The code looks clean and well-organized. Keep up the good work!
I have nothing to do with this PR, but I just wanted to add some notes here:
|
Love to see this additional section being added. I think knowing about both and understanding how they are different will help students when to use what. |
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 aboutbinding.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
pry
.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:
p
/puts
stuff, but I feel like some of it could be improved. It currently only mentionsnil
as a potential problem for usingputs
overp
, but there are a couple of other pretty significant distinctions to be made I think:p
returns its arguments, whereasputs
returnsnil
. This makesp
nice for reducing any thought or regard for how what you're adding to the code is affecting the way it functions.p
reveals a more "code"-like representation of objects. This is of course the reason behind thenil
thing, but I'd say the impacts of this go beyond justnil
.pry
focused. 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 coverp
debugging orbinding.irb
.Pull Request Requirements
location of change: brief description of change
format, e.g.Intro to HTML and CSS lesson: Fix link text
Because
section summarizes the reason for this PRThis PR
section has a bullet point list describing the changes in this PRIssue
section