Comparing Basic Programming Fundamentals To Music

Often times when I get stuck with a particularly vexing programming dilemma, I'll try and think how I can relate the issue to music, something I'm quite comfortable with.  For example, when I was first learning about the concept of functions and methods, and how they took arguments passed into them, I would think about how I hook up my studio gear.  The way sound gets passed through one component to another is a slightly similar concept (ok, there are actually many differences when you really think about it, but that's fine).

Another fun thing I like to think about is how there's so many ways to do the same thing in programming.  The different ways you can iterate over collection sometimes reminds me of all the different ways you can play the same thing on an instrument.  Like, on bass, I could play one baseline in like 5 different spots on the neck.  Each one would sound slightly different.  Similar concept with enumerables, only the results don't necessarily sound different...but they do produce different results!

For a beginning to intermediate programmer, relating core concepts to things you are already familiar and comfortable with is a good idea.  It helps to make programming less scary and more friendly.

CLI Data Gem Project

CLI Data Gem Project

For this project, I decided to create a CLI Gem that would scrape, to give the user data about many different vintage bass guitars. Since I am a bassist, I found the project to actually be super informative and actually really helpful! 

My original approach to coding this was based on Avi's video, CLI Gem Walkthrough. At first, everything was going great, but because I was perhaps a little too ambitious about how I wanted the data to be structured, I hit a wall pretty hard. I was assuming it was going to be easy to be able to search by Brand, Model, or Year. That proved to be very difficult, because searching by year would have to be a massive web scrape of over 100 websites within the domain. So after a full day of coding, I decided to scrap everything and start over with a simpler, more top-down approach.

After watching Avi's second video,, I decided to model my 2nd attempt after this structure (with some of the original structure as well). This worked out well, and was much simpler for me to see the data flow, as it was more in line with the code I've been working with in previous Flatiron lessons. My top-down approach made sense too. The user is presented a list of 5 brand to choose from (this was hard-coded. I didn't see it necessary to scrape the website for the brand names). Once the user makes their selection, a new instance of the Scrapermethod is created, which in turn creates a new instance of the of the Brand class. Once that happens, all the other Scraper methods are able to do their thing. The #scrape method is able to return a list of all the available models of that particular brand, and at the same time, make new instances the Model class, and add those newly created classes to the Brand instance. The user chooses which model they are interested in, from there the #scrape_instruments method is called, which returns a list of every year that particular brand was manufactured. It also creates a new instance of the Instrument class, and adds each instance to the Modelsobject.

Once the user chooses which particular year they are interested in (or, as it is defined within the code, Instrument, the scrape_description method is called, returning the description, as well as adding the description to the instance of Instrument. 

I had some major challenges doing the scraping, because the website I was scraping from is old, and has all sorts of weird drop-down menus, and menus within menus and all that confusing stuff. Also, the site was not coded with specific CSS class names. At best there were 3 or 4 CSS classes to start from. Eventually I determined the best way to get the data was via XPATH. Not ideal I guess, but it did work. After a few refinements, I was able to get data via iteration. One big challenge I had was string interpolation within an XPATH. When finding XPATH links on Chrome, quotes for CSS classes are single quotes. It took me some time to realize why my string interpolations weren't working: Because the #{}syntax only works with double quotes!!! I also learned about escape sequences within a string. Like, when you need to actually have a quote inside a string. So I learned about ` and all that good stuff. 

All in all, a great project! I was great to go out on my own and learn how to do things without the option of asking a question on All that trial and error throughout the process, as well as all the research, is what it's really all about.

Why I Decided To Learn Software Development

I first got excited about software development when I learned how to automate computers.  As a booker for music venues, I found that I could cut down my time doing tedious, repetitive tasks by at least half.  Doing this allowed me to focus my energy on booking good music.  It also created a more stable system of booking. It meant less typos, double bookings, miscommunications, and cancellations.  At some point, I started keeping track of every little thing I had to do more than once.  Anything that made that list would be automated.  I got every piece of software that could help with the automation process.  I learned AppleScript, and used it to control just about everything.  
I was so proud of all my scripts, I showed them to a few of my programmer friends.  The response I got was basically, "Dude, you're about 3 steps away from being a programmer.  You should just learn programming!"
It was around that point that I realized that I really enjoyed the process of scriptwriting and automation, not just because of all the time I was saving, but because it was really fun and challenging- I got a kick out of it!
So I started messing around with JavaScript, HTML, and CSS.  I took a few starter courses online, and had a really good time with it.    After doing a few of those courses, I realized I wanted to take it a step further and really learn how to use these tools.  I tried the Flatiron Bootcamp Prep course.  It was definitely the most challenging of all the programming courses I had tried.  But again, I really enjoyed the challenge and loved working my brain in that way.