Homework 1 Reflection
Coding
In total, I spent around 4-5 hours on this assignment. There are definitely some design decisions that I'll pay for in the future. If I spent a little bit more time on this I could avoid some potential refactoring.
A decent amount of time was spent trying to de-rust myself. Also, there were some things that I had to read and understand about Zod before I got comfortable.
Nothing in this particular assignment was particularly difficult, if I'm being honest. It was a fair first assignment for a web dev class. The assignment description was extremely straightforward and I have no reason to complain about it.
Typescript
The type system didn't explicitly catch any bugs for me. The bugs that I encountered were based on my lack of knowledge of Zod and sqlite3, and I expand on my experience with these bugs in the testing section. Typescript feels relatively friendly and not confusing to me at the moment.
Testing
The start to writing tests is always slow. You're pretty convinced something works because you use it and it responds the way you expect it to. I thought that writing tests was slow at first, but honestly it helped me uncover the small validation bugs (specifically the ones that I mentioned above) and better enforce the expected input and output from the API calls.
Some of the tests for invalid input revealed to me that I had to look at the Zod docs a little closer and that I had forgotten to bake in some Status 400 logic branches into some of my routes. I also learned from the tests that Zod will not fail a parse on input if it has additional fields compared to the specification. I also wrote some tests that revealed that a SQL query that is valid but does not return records will return an undefined object, which caused a logical bug in one of my routes that was undetected until I wrote the test for it.
I put all of my tests in one file for this assignment, simply because there were a relatively small amount of tests. In the future (probably the next assignment) I will separate out the tests into separate files for each handler. I can tell that the test suite can get much larger and relatively hard to read.
LLMs
I used LLMs when writing tests, specifically for dummy data. I wrote one book and one author object, then asked Copilot to generate several more random authors. Then, I asked Copilot to generate additional books using the IDs that were in the author's array.
In the context that I used them in, they saved me time and made the process more fun by removing what I believe is the most boring part about writing tests. I don't think they affected what I learned from the assignment.