-
Notifications
You must be signed in to change notification settings - Fork 13
Refactor
The main thing we changed the endpoints used in the backend. We made it so data isn't being passed around in path parameters anymore. Instead, a majority of any data being sent to the backend is now passed within the request body as JSON data.
Before, entities were uniquely identified using different fields such as the date_created for workouts. So, another change we made in the refactor is creating an ID field for all entities stored in the database (i.e. exercises, routines, workouts, etc.) to make it much easier to fetch a specific entity. This means that the only data that is passed to the backend as a path parameter is the entitity ID, better following RESTful principles.
An example of the change can be seen below:
Old endpoints for exercises (above)
New endpoints for exercises (above)
This refactor greatly improves maintainability since if we wanted to change the kinds of data being passed to the backend, we no longer have to keep changing the endpoints anymore. Instead, we can keep all endpoints the same and only change the request body.
For example, if I wanted to change the data being sent when creating an exercise with the old endpoints, I would have to edit:
to include new path parameters.
After the refactor, if I want to change the data being sent when creating an exercise, I wouldn't have to change the endpoint at all since the data is passed within the request body:
This means that it is a lot easier to make changes to the kinds of data that each entity has.
Furthermore, the changes to only use ID to fetch an entity from the backend made it a lot easier for us to do endpoint calls in the frontend. This is because, rather than having to pass multiple bits of information to the backend to fetch an exercise, we only need the ID. This also means that if future changes require removing certain fields from an entity, we can be sure that it won't affect the fetching logic since only the ID field is used.
For example, with the old endpoints, if we wanted to remove the sets field from exercises, it would completely break the fetching logic since it is required to uniquely identify an exercise. With the new endpoint, there would be no issues since we only use IDs to identify exercises.
Old endpoint (above)
New endpoint (above)
In general, the refactor helped us out a lot in A2, since it simplified the process of connecting the frontend to the backend, which was one of the main tasks that we were aiming to complete. Furthermore, it made it easier to make changes to the kinds of data we were storing in each entity, which was very useful when we were making changed to the things we wanted to display in the frontend.