Huffman Blog


Programming

RAILS!! CreatedToSell

For my rails project I decided to create a basic online shopping application. As always, my initial hopes for this project were much larger than time allowed and it ended up as half of the application I really intended to build, BUT IT WORKS! That’s what counts right? It also leaves me with plenty of room to go back, play with it, add to it, and sharpen my ruby skills in the future. I intend to do this with all of our projects. Nothing is ever “complete” is it? That may be one of my biggest takeaways from this project. One of many. As I venture down the developers path I am truly beginning to see that coding never ends. Learning about code never ends. Even with as much curriculum as we covered with rails, we barely scratched the surface. RAILS. IS. HUGE. Rais does SO MUCH without you ever realizing it. Rails writes HTML, Rails writes Ruby, Rails can even write some CSS. It is truly amazing the work being done behind the scenes when it comes to rails. It can be a blessing, and it can also be a curse. Because rails has so much going on under the hood, without a good understanding of what is happening and why it is easy to get lost in the magic. I found myself constantly googling what HTML a form helper would write, and how to organize my arguments to get the corrct output (collection_select is one I’m STILL looking up every time I use it. It has so many options available!) If I could go back to the beginning of this module, I would surely complete the HTML bonus section before proceeding to rails. I taught myself HTML roughly 5 months ago, and that is what lead me to Flatiron. Having said that, I realized that a lot of that knowledge was burried under ruby, sinatra, and rails. If I had done the HTML Bonus It would have been an excellent review and would have put me in an excellent position to understand exactly what rails was writing for me. In summary, I currently have a love-hate relationship with Rails. It is a very smooth framework, that has saved countless developers countless hours, but sometimes its almost to smooth. Slippery, if you will, and sometimes when things are slippery we fall. Luckily, many a dev before I have fallen down the rails rabbit holes and there are resources everywhere for rails help. And for those: a huge THANK YOU!!!!!!!!


Sinatra Project: SecretFamilyRecipe

I LOVED creating this Sinatra project. For the very first time I was able to take these months of hard work and create something meaningful and useful to my family and I. Now, don’t get me wrong, the CLI project was fantastic and I think it really sparked something in me. However, this is something I can share with those closest to me. I couldn’t tell any of my support group “Hey guys! Set up a local environment on your computer, go to my github, clone and fork my repo, and then in your terminal type bin/run!” I would have recieved blank stares in response to that. Their minds would have gone “Set up a what? Go to myd what? Do what and what to what???? I dont have any forks, just cookies… maybe… and i dont think I’ll be at an airport any time soon.” Needless to say, it would never happen. However, with this project I now have something that, with a little bit of extra work, I can slap on a free hosting site and say “go to www.my_project_url.com.” Short and simple, and something that anyone who’s ever used the internet can do. I would say that this project tested my ActiveRecord knowledge more than anything. I constantly kept returning to the ActiveRecord labs and lessons to refresh myself on things, especially setting up relationships efficiently. Why have a recipe belong to a user and a family when it can just belong to a family through user? One thing that I was sure I was being proactive about was my use of the SQL table “:families.” I knew that active record uses pluralization to determine a number of different things regarding to relationships. In order to be proactive I thought “ActiveRecord is taking the table name and stripping off the “s” at the end in order to find a Model that builds objects from that table.” By that thinking, I didnt want to confuse ActiveRecord with the singular family instead it needed to be familie. Right? Wrong. Turns out the folks who developed ActiveRecord were kind enough to take that into consideration. Active record DOES NOT just strip the s off of whatever you use for your table name. In most cases that is all it has to do, however there is an entire library in ActiveRecord dedicated to irregular pluralizations. Families included. As far as readability of code, that’s an awesome thing. While I may have spent a good two hours before I finally realized the issue, I learned a valuable lesson:

Have faith in your fellow developers. Especially developers of a major component like active record. They foresaw this, and while I may have wasted time because of it I’m sure there are countless others who’ve benefitted immensely from that library. It also showed me to think ahead as far as ease of use goes. My experience showed me that active record was stripping off an “s.” (I had never used an irregular plural like this in a table before.) If I had been someone picking up active record for the first time, I would simply type it like it was english. Like it should be. And if it weren’t for that library I’m sure countless people would have wasted countless more than my two hours trying to figure out why families wasnt the table for the Family model. Another issue I ran into was determining when a method needed to be a helper method (belonging to a controller), and when it needed to belong to a model. My recipe’s were created with attributes like prep_minutes and prep_hours so in order to find the total prep time I needed a method #total_prep_time. Without really considering WHAT this method was going to do and WHO it was going to do it to I placed them in my recipe helpers. What do you think was returned when I tried to call:

def total_prep_time
   "#{self.prep_minutes} : #{self.prep_minutes}"
end

on an instance of a recipe, when it was DEFINED in the controller.

No method error: no method 'total_prep_time' found for object <RecipeController>

OOPS! “Lets just copy and paste that over into the Recipe model!” 01 : 30 YES! The moral is it matters where things are defined. You can’t find a prep_minutes from something whos attributes are :params, :session. Going forward I will always be considering WHAT a method will do and WHO it will do it to.


SpaceX CLI

Creating the SpaceX CLI was a project that I thoroughly enjoyed. It was not only the first time creating a working program (outside of Learn lessons, of course), but it was the first time working with a data set that I am genuinely interested in. I am very pleased with the finished product. I was even able to get creative and use gems for color, and add some ASCII rocketship pictures printed to the terminal!
 In the end, while I did not struggle with too many portions, this project still had much to teach. I learned to read an API, and translate that into ways to access each of the different data sets I needed. I brushed up on string interpolation and using variables inside of strings to construct paragraphs that make sense when different variables are passed in.
 What I struggled with the most with this project was using other developer's gems. I found that some gems I had tried using did not have the best documentation to go along with them. This lead to a misunderstanding of the correct uses of the gem's classes and methods. It taught me that no matter how simple something seems, it is a good idea to have thorough and accurate documentation describing your code.
 This project also gave me a basic understanding of Github, its uses, and how to correctly set up a repo and push to it. I struggled with this when I accidently set an incorrect path for my project's origin. This lead to a lot of "fatal" failures. As a novice programmer, when the word "Fatal" shows up in my terminal, I get scared! However, this was a simple fix that only involved a simple git command in the terminal (git rm origin) to remove the incorrect origin, and add the correct one! This experience also taught me to PAY MORE ATTENTION! When I set up the origin, i simply left out ".git" and the next thing I saw was Mortal Combat's "FATALITY" at the bottom of my screen.

What Is My Why?

I decided to learn to code due to Covid-19. I was laid off in March 2020 from my job as an electrician. My father was an electrician and I watched him struggle during the housing crash in 2008. He recovered, however was also laid off due to Covid. I made the decision that I will not live this struggle of layoff after layoff that I have watched him endure through life. My wife and three children depend on me, and i refuse to let them down. They are my real why. As an electrician I regularly spent many weeks away from them for work. I missed my youngest son coming home from the NICU because I was gone for work. I refuse to set my personal life on the back-burner in pursuit of a dollar. While I am realistic and understand that software development is not an easy job, it is a path that will see me home much more often. To me, that is the biggest benefit of changing careers.