Coding
How long did you spend on this assignment? ~Roughly 3 days. This includes both the time spent coding and debugging issues.
Where did you spend the most time? I spent most of my time designing the API and writing tests. Designing the API required careful thought about the data structure and how endpoints would interact. Writing tests was time-consuming as well since I had to ensure proper test coverage and handle edge cases.
What did you struggle with the most? What would’ve improved your experience on this assignment? I struggled the most with the design process, particularly deciding how the API endpoints should behave and how they would interact with the database. It was challenging to predict potential edge cases without an example or a reference implementation. An example API structure and a few example endpoints would have been extremely helpful in clarifying expectations and saving time.
TypeScript
What are some of the issues TypeScript helped you prevent? TypeScript helped catch issues like:
- Using undefined or incorrect properties in objects.
- Passing the wrong types to functions or database queries.
- Typo errors in object keys, which could easily go unnoticed in plain JavaScript.
What are some of the holes in the type system? While TypeScript validates types at compile time, runtime errors like invalid database schema relationships or unhandled exceptions still occurred.
Using plain any or improperly typed libraries created areas where TypeScript couldn’t help.
Testing
What was your experience writing tests? Writing tests was a mix of rewarding and tedious. It was rewarding when I could catch bugs early or confirm that the API behaved as expected. However, debugging failing tests sometimes felt repetitive and time-consuming.
Did your tests help you find any bugs? If so, which ones? Yes, they helped me identify:
- Missing validation logic for fields like id and author_id.
- Bugs in error handling when an author or book was not found.
- An issue where the API returned 200 OK instead of the correct 404 Not Found for invalid IDs.
What did you learn while testing? I learned that thorough test coverage saves time in the long run. Writing tests for both happy and test cases ensures that APIs behave predictably. Testing also forced me to think critically about the design of my endpoints and their responses.