Creating an API

We wanted to create a find method that would enable us to access any given Adventure, Objective, or Narrative instance. Each Narrative belongs to an Objective, which belongs to an Adventure, and all of these have unique ids.

We wanted to be able to look them up by the ids. Each individual objective is an instance of the objective class.

API stands for Advanced Programming interface and is basically anything you can use to request information. Our API will request information about instances when it passes in the id.

We discussed the difference between private and public methods, and explained how protected works.

We wrote a test for this, even though this story was a chore. One thing to remember is that if the code executes in production, there should be a test for it, even if it's a chore.

Published on