My First CLI: A Lesson in Patience

Melissa Guachun
4 min readMar 3, 2021

--

As Phase 1 was coming to a close, I felt the looming presence of our first project. After six weeks the moment came when we were presented with our project serving as a culmination of all our knowledge (so far).

The project prompted us to create a CLI that retrieves and shows external data. I decided to make a CLI that shows users the latest released movies from my personal favorite movie studio A24 Studios. Because of my niche theme I had no option but to scrape my data. Going into this project I didn’t totally grasp the difference between using an API and scraping. I just knew scraping to be a last resort if the information is too specific. At the time I didn’t see this as a red flag rather an invitation for me to receive an in depth overview of scraping. Looking back on it now, I see it as a lovely invitation made out of a bunch of red flags.

Thank you to my instructor and classmates for their feedback and support through this phase.

I learned pretty quickly that the battle wasn’t so much writing the code but getting it to execute. I must have spent more time having my friends walk through my code with me than I have actually coding. It brought to light how important it is to go into a project with a written down plan. Even though I wrote down my goals and intentions for this project, I wish I had taken the time to make an even more detailed layout. Doing so would’ve allowed me to better visualize my code flow and structure.

A common problem that I struggled with was understanding which methods fit into the CLI file, the scraper file, and the film file (objects file). This was the first time I had to jump between files which became disorienting when orienting objects. I found I would often place code in the wrong file or write redundant code. I feel like this could’ve been remedied with going in with a more detailed layout as I mentioned earlier. My understanding of how the files interacted with each other was still shakey which caused me to reach out for help.

Watching my peers present their progress and having a new set of eyes look at my code was the most beneficial feedback. It brought up another important aspect about programming where in order to understand you have to code and learn to talk about your code. Stumbling upon my words and blanking out on simple questions at first made me question my memory for the past 6 weeks. But in essence I was debugging my own confusion by talking through my code. Conversing about my code helped establish a more concrete understanding of the function of my code in each file:

cli.rb: This file contains the interface that the user will interact with! I thought this file was particularly fun with programming because it illustrates how ruby runs operates with the input given by the user. Creating this file offered a lot of room for creativity and aesthetics that I’m excited to dive into more over time.

scraper.rb: This file is where the upcoming film collection data is collected.
To assist in retrieving my external data I used Nokogiri and open-uri gem. Open-uri sends HTTPS request to the site I’m scraping to access the data. Nokogiri is then utilized to filter through the data and enable me to scrape the data through HTML/CSS tags. As frustrating as it was at times, I found scraping for data almost being like a puzzle of inputing the correct tags to scrape the correct data.

film.rb: This file contains data obtained from the scraper file where objects are created. The characteristic of title is initialized into an array of upcoming films that is displayed into a list for cli.rb. The file contains methods like def self.list_film that iterates through the index and film objects by placing a number next to the film object title within the list of films.

Conclusion: This project really challenged my knowledge as someone who is new to Ruby and object oriented programming. As helpful as the labs were, the freedom the project allowed became easily overwhelming and daunting to tackle. It reminded me how important it is to go in with a plan to prevent getting lost along the way. There were days where I felt like I was on top of the world and making progress. And then there were days where I didn’t think I was going to make it through this project. Out of everything I think the most important lesson I learned was patience. Don’t expect to see immediate progress because this project forces you to thoroughly assess your code to be clean, dynamic, and functional. It really gives you insight into the emotional rollercoaster of being a programmer because just when you think you understand a concept, you’re only scratching the surface. But that’s okay! You don’t have to know everything! I can’t walk away from this project with the confidence I know everything about object orientation or Ruby in general. But I can continue on with my coding journey with the idea that with a little bit of patience and help from some friends, anything is attainable.

--

--

Melissa Guachun
Melissa Guachun

Written by Melissa Guachun

Software Developer and visual artist based in NYC. Join me on my journey to coding enlightenment or a torrential mental breakdown, whichever comes first.