You can find the Reflection For Homework 2 here :Homework 2 Reflection.
You can also find the Reflection for Homework 3 here:Homework 3 Reflection
Coding
Time spent: I spent approximately 2 full days on this assignment.
Where most time was spent: The majority of my time was spent debugging my request handlers, fixing configuration issues, and dealing with unexpected behavior in TypeScript, such as mismatches in response types and type-related errors. Additionally, a significant amount of time was dedicated to ensuring database queries worked correctly and did not result in duplicate insertions or other issues.
Struggles: I struggled with a combination of TypeScript and runtime debugging. Issues such as incorrect destructuring of objects, untyped or mistyped responses, and difficulties configuring dependencies (e.g., ensuring all imports worked correctly) took a lot of effort to resolve.
Improvements: Having more examples of how to debug TypeScript effectively in this kind of project setup or clearer guidelines on designing robust APIs would have significantly helped reduce the time spent debugging.
TypeScript
Bugs TypeScript helped catch: TypeScript caught several issues, such as:
- Incorrectly destructured objects from API responses (e.g., trying to destructure properties from undefined objects).
- Mismatched types between expected and actual function parameters.
Bugs TypeScript did not catch:
- Logical issues like duplicate database insertions due to the interaction between test setup and handler execution.
- Errors arising from runtime issues, such as API responses failing due to invalid database operations.
Struggles with types: I struggled with typing Axios responses properly, especially when handling errors. For example, accessing `response.data` properties on an AxiosError was challenging as TypeScript flagged them as `unknown`. Understanding how to handle union types in response objects is still something I need to work on.
Testing
Experience: Writing tests was both rewarding and frustrating. It was rewarding because well-written tests ensured my API behaved correctly, but debugging failing tests, especially when the issue was with the test setup or database state, was frustrating.
Impact on development: Writing tests helped me uncover several issues:
- Duplicate insertions caused by the `beforeEach` setup in tests inserting data already inserted by POST requests.
- Improper handling of error responses in the API, such as unhelpful or misleading error messages.
Future improvements:
- I would structure my test setup more carefully to avoid unintentional duplicate data insertions or stale state issues. Using `beforeEach` and `afterEach` consistently to clean up the database state was a critical lesson learned.
- I also learned that testing error cases is as important as testing success cases, as it helped reveal weaknesses in error handling logic.