loading...

The Journey to My First CLI Application

turpp profile image turpp ・4 min read

Hi! My name is Tripp and I am a member of Flatiron School. I want to share with you my journey in creating Movie Madness. Movie Madness is a CLI application that I made with Ruby. Movie Madness is designed to gather information about movies and then organize them in a way that is fast and easy for the user to get and understand.

Alt Text

The first step was to get the data. There were two main ways to get data for my application. I could either scrape or use an API. I decided to go with an API. An API is basically a service that allows developers to have easier access to information from the provider. I used TMDB's API to get information about movies. The API only pulls information 1 page at a time. To fix this I just ran a loop to pull multiple pages of results and add each page to an array. After the loop was complete, I had an array of hashes full of movie data.

Alt Text

Tip: API’s are super powerful. I could easily make a request to the API any time I want information on a movie or to get a certain group of movies. When you make multiple request to the API you can run into two problems. First, it takes time and the second, it opens up the possibility of getting different information if the API updated between request. To fix this I made a global variable. I called it clean_data. This allows me to store all my data in one place and use a single source of information. This speeds up the program and also keeps my information consistent.

Alt Text

Once I got my information stored, it was time to create my objects and start manipulating my data. I had two main classes for my information. I wanted a class to keep track of all my movies and a class for genres. Once I establish my classes I was able to create some instance methods that would allow me to store instances from the data, format my instances, and also present the data in a way the user can use.

Alt Text

Tip: When creating classes and the methods it is critical to keep the end in mind. One thing that helped me a ton, was to comment what I was trying to accomplish. At the top of each of my classes I would comment exactly what I need this class to do. This would act as my checklist to make sure I got everything needed coded. Also, whenever I made a method, I would comment what I needed the method to do and then code it out by those steps. This help keep me on track and make sure I covered everything.

Alt Text

Alt Text

After I made my classes, it was time to start working on what the user would see. I wanted a simple app that was fast and easy to use. I got out a piece of paper and did some doodling of what I thought would look the best. Once I had a picture of what I wanted I could go ahead and start coding. This step required a lot of trail and error. I would code something and then run the file to see how it looked. Its a little tedious but I learned that doing one section at a time as I progressed through the app was the most efficient.

Alt Text

Tip: When you organize your code inside of your class, pay close attention to how you name things and how they are grouped. When I first created my class I had methods all over the place. As I edited and perfected my code, I spent a lot of time looking for the right methods. I discovered that if I grouped all my methods together by what they did, it was much easier to find the method I was looking for.

Alt Text

One Last Tip:
Create a foundation and then build on top of it. Tons of features equals lots of complexity and is a good way to get overwhelmed. One thing I learned that saved me major time was, whenever I had a working application I would create a copy of that file before I changed anything. When I made changes, I would still work in the original file, but if I ever got to a point where I was lost or didn’t know what I messed up, I could just delete this file and go back to the last working edition. This gave me a safety net. I felt free to add features or refactor my code because I knew if I did something to break the app I could easily revert back.

Alt Text

These tips are things that I will use in any build I do in the future. They help me be efficient and thoughtful in my process. I would encourage everyone to try out these tips and let me know how they work for you. Who knows, it may be that last missing piece you need to make the next big thing!

Alt Text

Discussion

pic
Editor guide