Week 4
Tags: ruby, bootcamp, journey, coding
Published: 2021-02-24 04:02:12

Alright!

So, as the title suggests I, along with my fellow cohort-mates, have successfully completed week 3 and pushing into week 4. This is the end of our first phase where we push our knowledge over the course of the phase to our absolute limits! This has been a challenge for sure but a rewarding one at that. As much as I've stared at the screen, lost for thoughts on where to go next, I've equally felt the rush of conquering my hurdles. 

Week 4 is where it all comes together. We were presented with the task of creating our own command line interface gem! At first read, my nerves jumped for sure. At second read, it was grind time. 

I heard that project week was going to be tough. Many times. So much, that I wasted no time and began doing my research so that I could be as prepared as possible when it came time. Suffice to say, when it came time, I was confident in my abilities to get all the requirements settled. 

My project idea was centered around the aid of my fellow cohort-mates. I wanted to create something that could help relieve some of the stress & anxieties that people were facing as they stamped through the lines of code. Thus, "Inspirational Stress Reliever" was born! The user is greeted, asked if they're feeling stressed, and provided as many inspirational quotes as they want! One of the requirements was to make sure the program went one level deep. My idea for this was at the end of attaining their quotes, the user is read a list of their quotes and provided an option of selecting from their list, the author of any provided quote. That's just about my program's cli in a nutshell. Sounds simple enough. Until you check under the hood. 

My project went through many, many changes. This is due to both the creative freedom Flatiron offers for this project, and the requirements. The overlaying goal is to make your program object oriented. This means you are CREATING OBJECTS and working WITH OBJECTS!!!!!! Note, this is not me screaming at you, dear reader, but to my past self. The first version of my program had grabbed information from my api(which grabs the random quotes as hashes containing the attributes of the quote) straight from the cli. Big no-no. The idea of object oriented programs is to separate your concerns, which means you don't have just one class doing everything but separate that do, separate things. Excuse the layman terminology. After I got that down though, was where the real fun began. 

One change I want to mention was centered around user interactivity. At first, the user was presented with choices like so:

```ruby
print "Enter 1 for 'yes', 2 for 'no'
input.gets.strip
```

Yikes. 

Although not the worst way to present text for user input, it is definitely not the prettiest. My solution for this came from my wonderful cohort leader, Laura Berge. She had suggested I look into the ttyprompt gem to make my cli more user friendly. Looking through, I had agreed and proceeded to download the gem and work through implementing that gem. And so, my program went from that super robotic formation into:

```ruby
prompt_1 = TTY::Prompt.new
            puts ""
            prompt_1.yes?("> Would you like to know any of the authors?")
```

Although you may not be able to tell, this makes a world of difference. Now instead of entering 1 or 2, from which I would have went into 2 other methods for wrong input and to return usable options, the user can enter y/n (which is displayed next to any question) or yes/no. On top of that, if the user inputs anything else it automatically produces an output for invalid input AND turns the user choice green. This was a game changer. My program is a lot nicer to look at and I'm a lot more confident in presenting to others. 

This is just another stepping stone in the field of becoming a Software Engineer. I've learned a lot in so little time and I couldn't be more grateful. Words can't describe how excited I am to see where the next hurdle takes me. 

Until then,


Nathan Hains