Familiarize Yourself with the Console

James Hoggard
4 min readMar 30, 2021

Just some advice

As an individual first beginning their developer journey I encourage you to familiarize yourself with the console. The order of your curriculum may differ from mine but I believe the advice still applies. It’s not uncommon for things to be difficult when learning something new, but shortening that adjustment period always seems to help. There are a lot of things you can do to help that process along including pseudo-coding and reading ahead but I’d like to bring your attention to the console, preferably the Pry console as opposed to irb. They say that if you’ve received good advice you should pass it along.

Just Starting

It’s possible that you could make your way through all of pre-work and the beginning weeks of your software engineering program and barely even use the console and that’s probably not how it should be for a beginner. Perhaps you should also make a test file of your own if you feel uncertain. That way you can test things without being concerned about altering your work or just continue to play around with ideas while you get your footing.

Early Phase 1

There will be times when you will not want to call a method on your class object and rather just want to see all the instances of that class and how they are ordered in that particular array. In other situations you may just want to check that the class exists. “Did ActiveRecord really carry over so that I can check this object’s column names another way?”. You might ask yourself why a string is separating a certain way after calling the split method on it(see img1). Maybe you just need to see visually what the information assigned to a new instance of a class presents like. Some syntax highlighting could be in one’s best interests. I am more of a visual learner so I can relate. Perhaps you just want to see what is returned when the last method is called on that class, or if the belongs_to relationship that you thought you established earlier was effective? By opening the console and using a binding.pry in the right area we can get closer to figuring out why that object orientation did not take place.

Earlier on requiring and setting the binding.pry was necessary
Now not so much

A Couple Days Pass

You need to see what Student.all actually looks like? It’s important to open up the console and check that you were successful in migrating and seeding your database. Or maybe you just wanted to see if all of your seeds were destroyed?

Destroy those seeds

Go in there and actually see how .sample decided to randomize a certain attribute. For some reason it may have only randomized to 3 instance objects out of your expected 10. By at least being in the console you can identify that “computer error”. Maybe you want to instantiate a new Person, or figure out why your apply_discountmethod isn’t working. It’s possible you might come to the conclusion that something may work better as a hash upon seeing it as an array while in the console or vice versa. It’s conceivable that after learning that your input in rails console returned an array, you are now able to determine how to solve your problem💡.

Recap

Now if that sounds like a lot to think about, don’t worry because it’s just month #1. As you understand more of the console environment start sprinkling some binding.pries in there too. Part of your success in the program will depend on understanding and recognizing what you are being presented with. The console gives you another opportunity to learn the properties and the structure of what you are being presented with.

Maybe I’m wrong and you just wanted to see the difference between puts and print. But regardless, it would behoove you to familiarize yourself with the console. By not doing so you could potentially set yourself up for writing lines of code that will eventually be of no use to you among other avoidable mistakes. Before I possibly forget some of this experience acquired information in the next phase, I just wanted to let you know. Good luck and in the words of the legendary Joe Gibbs..

“A winning effort begins with preparation”.

--

--