DEV Community

Cover image for My CLI project: The League...
Gia Jennings
Gia Jennings

Posted on

My CLI project: The League...

Welcome to The League ...

The League is my CLI program in which you are now an NBA general manager and can pick your team, to uncover team details. These details include your team's full name, city, conference, and division.

This was hands down the most difficult project I've had to complete in my educational career. However, I learned a ton; implementing object orientation, using an API to access data from an outside party, style and construct an interactive program, etc.

The process was an interesting one and planning definitely helped. Taking my cohort lead's advice to build out piece by piece and test each part helped so much.

  1. Plan out the order in which you want things to run as your user interacts with the program.
  2. Build the folders and files needed.
  3. Structure each class (API, CLI, etc.)
  4. Style the interaction... can never go wrong with adding some ASCII art.

Alt Text

Wrap that up and you got yourself a working CLI program. (It feels good to finally say it's "working" lol)

While I reflect on the overall project, I'd like to touch on one portion that was really giving me issues; the API class.

Alt Text

Started with the initialize class method which set a local variable (@url) to the url that included my desired API data. This made it easier to call once I wrote the next class method (@get_team), where the user would be able to make a new instance of a team and use the API data to get all the information. Next, I structured this method to access the keys and values of the api and use JSON to parse the information. JSON is used to receive, send, and interchange the format of data. As you can see, I used JSON to parse the objects in the provided hash. Lastly, I ended the method with the ability to create a new instance of a team, from the information.

(Still working on the coding vocabulary lol)

Setting up this API class is crucial to the entire project to prevent the need to hard code strings of data. Simply used data already provided, mass assigned all the available attributes, and used the objects I wanted to display later on.

All in all, this was a big challenge for me but I learned so much and feel a great sense of accomplishment. I look forward to completing more challenges in the remainder of my time at Flatiron School.

Top comments (0)