Back to Main Site
Homework 1 Reflection
Coding
-
I spent around 3 hours working on the API and another 1-2 hours on
testing.
-
The part I struggled with the most was the design of the API and
figuring out how to write in TypeScript what I wanted to do
conceptually. Something that would've improved by experience on this
assignment would be to get more familiar with TypeScript beforehand and
refresh my memory on Javascript concepts.
TypeScript
-
Some bugs that TypeScript caught were mismatches between Zod schemas and
database types (e.g., author_id as string vs number), incorrect return
types from database queries. It didn't catch all issues, such as missing
properties in test objects. Some holes in the type system included the
use of 'any' type from sqlite3 library and runtime validation gaps with
Zod.
-
Some values that I found confusing were the intersection types (BookDB =
Book & { id: number }) and how they helped separate API input types from
database types with IDs.
Testing
-
I liked writing the tests, it felt similar to writing tests in SE181
with trying to think of all the edge cases and making sure I covered
them. It was a little boring since author and books had overlapping
tests. Overall, seeing all of the tests pass at the end is rewarding.
-
One bug that the tests helped me catch was incorrect filtering logic for
pub_year. I needed '>=' instead of an exact match.
-
For the future, I'd add more edge cases (empty strings, SQL injection
attempts, concurrent requests) and separate unit tests from integration
tests. I learned that comprehensive testing is crucial for catching
subtle bugs and ensuring robustness.
LLMs
-
I did use LLMs to help with mock data, when I had repetitive test cases
or endpoints for both author and books, and replacing the start code
'widget' with either 'book' or 'author'. I also used it to help me with
debugging and not knowing syntax.
-
Using LLMs made the experience more fun and saved me a lot of time since
it allowed me to focus on how to design the API instead of getting stuck
on syntax issues or coming up with mock data. I think it helped the
quality of my code and identify Typerscript patterns and SQLite quirks
faster.