Professional Documents
Culture Documents
REST apis are a type of Web Service Architecture. REST stands for Representational State Transfer. In a
REST api, web services communicate using the HTTP protocol GET, PUT, PATCH, POST, and DELETE
methods with data in json format in the body of the HTTP message.
I learned both how to use a REST api, like the public openweathermap api, and how to build and define
my own api. I also learned the difference between using a REST api to communicate between services
and a message queue like rabbitmq. REST is synchronized while a message queue is asynchronous, so
the code does not sit and wait for a response. After sending a message using HTTP, the HTTP protocol
dictates the code must wait for a response whether that be an HTTP 200 success response or an HTTP
404 not found error response.
Testing
I learned how to create junit tests using Mocks so that the tests could run faster without making an
actual connection to the database. I also learned that unit tests should not be written for each method
as I always thought but should instead be written for each action a user can take. Using the phrasing
“given x, when y, then z” to define tests, is a helpful way to think about testing what should be returned
or set for a given user input instead of what interactions should occur. State testing is less brittle than
interaction testing because it focuses on what the public-api promises the user of the code, not on the
implementation details.
I also learned that it is better to ask for help than waste days debugging and trying to fix defects on my
own. It is hard to track down some bugs, like when half of the imports were from junit v4 and half were
from junit v5 creating a strange error with not much to work off of for debugging. I wish I got a chance
to do the assignment on how to use Selenium for end-to-end integration testing but did not have time.
Instead, every time I pushed code, I had to go to Heroku to see if the build was successful, open the web
app and MySQL to see if everything was working as expected and saving or deleting from the database
properly, and open the Postman tool to test the api. I learned having an integration testing tool would
be useful.
Concluding Thoughts
There were many mistakes made along the way during this project. This project and this project report
have been a good learning opportunity on how to do a failure or root cause analysis when project goals
are not met to avoid repeating the same mistakes next time. I hope to implement these lessons in future
projects.