Building a CLI Application from scratch for the first time is no joke but without a doubt, will make you a better programmer.
Project week was finally here! My mixed emotions between happiness and nerves were very real. I set a realistic first goal with this project: understanding how every file gets connected to each other. 5 days ago I was totally clueless about it. It’s not the same to open the labs in learn.co where all this part is done for you and you just need to code and solve error messages. This time it was just me and VSC. To be honest, I was just following the steps in one of ours office hours lessons without really knowing what did what, but trust me, now, at the end of the project I can tell you what my environment file does or why we create objects instead of using just a hash with keys and values to make things run.
Talking about objects, now I have a WAY BETTER understanding of what they do and why are they so important. My CLI project is about an English to Spanish translation app for travelers. When I first started working on the project I just wanted to make things work and run. Like I said before, I set up all the files in my folder but I was not sure how to connect them. My first instinct was to create a hash with all the translations from the website a was scraping and use that to run my CLI. My plan worked. I had a functional application without objects. Later I realize that for this particular project I actually needed to create objects to do that (because after all, we have been learning OOP for a reason!). To be totally honest, at this point I was thinking... but, what is the point? My app is working and looks good, what’s the difference between creating objects or no? I learn really quickly what was the difference. These are two of the most important things I learn about objects:
1. Data storage: objects are a great way to collect data. You can add any type the information about your object in a comprehensive way. You’re not limited to just a set of attributes. If down the road I would want to add another language to my translator it's as easy as adding another attribute with the new language name and just storage the translation of that term or phrase in that attribute. When you are new at coding sometimes it's difficult to see the bigger picture. That’s why I thought my hash would work just fine, but what if I have 20 languages after that? Objects are without a doubt the best for that.
2. Logic: the way the data is presented through an object is just easy to understand. When we write code, we’re not just writing code for us. The goal is to share your code with other programmers in a logical way. Let me tell you something, it can’t get any more clear that creating objects (maybe later I would learn that it’s a better way, but as right now objects are everything!). I created a class (Translation) and one of the attributes of my class is (:spanish). Can you guess what happens if we use Translation.spanish? Well, I guess if you’re reading this you’re a programmer so you know what happens, but the beauty of this is that even someone without any coding background could guess that Translation.spanish would return the Spanish translation of that phrase.
Yes, it was a challenge to change from my safe hash to the unknow objects, but thanks to that, today I feel I’m in a whole new label. I’m still a beginner, but thanks to this project I can finally start seeing why Software Engineering is such a fascinating, frustrating, and totally rewarding career.
Thanks for reading.