loading...

My Portfolio Project journey

ggebre profile image ggebre ・3 min read

During the first month of being a student at Flatiron bootcamp school, I learned and practiced on how to use ruby in programming in solving various kinds of problems. I was required to create a Command Line Interface application as a requirement to completing the first phase of the bootcamp. The application should either fetch data from an API or scrape a website of my choice. I chose to fetch train arrival times data from Chicago Transit Authority’s API.
As I needed to use an api key to fetch data from CTA’s API, I requested for the api key and received it . After I received the api key, I experimented on the various endpoints that CTA provides to access their data. Even though the API has both train and bus tracking capabilities, I decided to use the train tracker api to develop my CLI application using ruby. I, then, design what the user interface should look like after I considered what the user requires from the tracker and what the API can provide to satisfy the user.

I started the application by creating five classes. One class, cli class, where all the other classes interact to display data to the terminal and prompt user for input. One class was used to fetch the data from the api and return the data for the other classes to use. I used two classes to model train station and the routes of the trains. I used the last class to create interface for the fetch class and the two model classes.

Using these classes, I managed to create a working CLI application. When the application is run from the terminal, it first displays the list of the routes that was saved in the route instances of the route class. The user is then prompted to select one of the routes and enter as input. The input is then used to fetch the list of stations that the given route goes through and displayed to the terminal. And the user is then prompted to enter the name of the station from which they are departing. When the user enters the name of the station, the application fetches the arrival times of all the trains at the given station.

Even if I had a working CLI application, I was not satisfied with the structure of the classes and the methods. I, then, started refactoring each of the classes. However, refactoring took longer than the time it took to get a working application. I restructured the classes so that I can have only four classes by combining the station model to the route model. Some methods of the classes were tasked to handle more than one task. I had to break up these methods so that each method can handle only single task. Moreover, I employed MVC arcticture in such a way that I have two models - fetch class and station class, one controller class and one view class.

The project has helped me strengthen my understanding of the contents that were covered in the first phase. However, the application needs improvement. The application can use the bus tracker api to fetch the bus schedule. In addition, I need to improve the readablity of the code as I think it needs to be more expressive when it is read.

Discussion

pic
Editor guide