The Little Things That Break My App

Alex Sahli
4 min readSep 8, 2020

As I learn how to code, I seem to both increase the depth of my knowledge and see that no matter how much I know, I’m just one letter away from my terminal asking me what I meant. Its frustrating, but almost unavoidable, even when you think you’re being extremely careful. I’ve found a few things that have helped me reduce the amount of errors I’ve been seeing while writing Ruby lately, and it definitely helps increase my speed, as well as reduce frustration. Since I really don’t mind using myself as an example, here are the errors I usually run into, the face I make when I see them, and how I’ve come to fix them!

Not Enough Ends/Too Many Ends

This one is easily the one I run into the most. When this happens, its usually because I tried to write a method with end already at the end before writing any logic, and then add an extra end after that logic is written (that I didn’t actually need). Easily found and remedied with Ruby’s error reporting, I just have to make sure my syntax is actually correct. I’ve started to remedy this by using bracket notation, as the end is not needed when I choose to do so.

Wrong Number of Arguments

Arg is coincidentally the sound I make when I see this error. I usually haven’t thought through which variables are entering the method and tried to put an extra variable where I would normally be referring to the instance I’m working with. Again, pretty easily remedied with Ruby’d error reporting, but slightly less clear what I did to mess this up, sometimes. I’ve become more mindful of how the attributes are arranged in my objects and how thats important when relating them to each other so that I can avoid this issue.

My Pry Is Stuck?

Sometimes, I’ll run tests on a Ruby app I’m working on, and it works, stops at the binding.pry, and allows me to use ‘pry’. Once I use it, it will print me values until a certain point and then be unresponsive. I found that it was due to the window size Iwas using, and that simply typing ‘q’ would bring me down to the bottom of my terminal to display the rest of the values. This works for me in VSCode, your mileage may vary.

Everything Looks Good, Why Doesn’t This Work Now?

“Weird, I seem to have everything written out correctly. It doesn’t LOOK like I have a syntax error. I’m pretty sure all my variables are defined correctly and my tests are set up fine, and everything was working until a few minutes ago. Maybe if I DELETE EVERYTHING IN THIS MODEL AND THEN REWRITE IT…. It works now? Oh. Okay.”

This is a thing, and it WILL happen. The scale might not be on ‘rewrite entire models’, but every now and then there will be an errant ‘invisible’ character breaking your code (especially if you’re copying and pasting from a messenger window). This is usually pretty easy to catch, as nothing will work, but harder to fix without rewriting everything, mostly because it’s totally unclear where your error even is in some cases.

This Is A l, Not An I

Make sure your text editor’s font is clear about distinguishing the two, and please make sure you get some sleep! :D

Although I’m having these small issues sometimes, I feel like with repetition I’m becoming more adept at writing clean, legible code that works. The errors give me more information about how Ruby is running my code, and in the long run increases my knowledge of why I’m getting the results I am when it *DOES* work. Its also interesting to see what happens when you transfer text between editors, I would have expected things to be exactly the same as long as you’re using the same font. I’m enjoying this so far and soon will get into a whole new world of issues with Rails!

--

--