Homework 1 Reflection

Coding

1. How long did you spend on this assignment? If you don't remember, give a rough estimate. It's okay if you spent very little/a lot of time on the assignment - answering this question honestly will help us figure out how to balance out this course.

I spent roughly 10 hours on this assignment. Understanding zod and Vitest, adding all the necessary components of this assignment, and writing all the tests took up a lot of time in the end. I could probably have used AI to speed up writing the tests, but I wanted to make sure the tests worked as I expected.

2. Where did you spend the most time? Fixing configuration, figuring out Typescript, designing your API, writing tests, debugging your request handlers, etc.?

The majority of my time was writing my tests and debugging my request handlers. Typescript is just adding types to things. Designing my API felt straightforward with the knowledge I had from Web Development (CS 375). However, writing the tests is new to me. Debugging my request handlers naturally took some time to figure out whenever I had issues.

3. What did you struggle with the most? What would've improved your experience on this assignment?

Nothing was difficult to do for this assignment, but was things were annoying to figure out. SQLite's syntax was not clear to me at first. For example, to check whether a delete actually removed a row, you need to do: result.changes === 0. Instead of "$1", it is "?" for positional parameters. It also took me a while to figure out that there are different commands you can run on the database (db.all, db.get, and db.run). For things like this, I used AI since I did not want to go through documentation.

I think it would be helpful to have a short reading available for SQLite's syntax and how to do common things with SQLite. For instance, the provided zod documentation (https://github.com/colinhacks/zod) helped explain how safeParse() worked, which was nice.

Typescript

1. Keep track of the bugs Typescript helped you catch and the ones it didn't catch. What are some of the issues Typescript helped you prevent? What are some of the holes in the type system?

In my POST request handlers, Typescript ensured that the fields I was unpacking from the request body were what we expected to be present (based on the type). In POST /author, for the line "let { name, bio, } = parseResult.data;", adding additional fields (not found in the Author type) will cause a type error. I accidentally had additional fields that were prompted deleted thanks to the typescript errors.

Also, in some instances, I incorrectly typed the response body of Axios and database sqlite3 calls. This caused issues later when I tried to get fields within the response body. Typescript would say that the field did not exist in the response body. However, after giving it the correct type, the errors (appropriately) went away. In this case, Typescript ensured that only the expected fields were being assessed.

One of the holes in the type system we discussed is the "any" type. Sometimes, if we can't figure out the type of something and it is slowing down development trying to figure it out, we use the "any" type (to bypass the type expectation) and figure out the exact type later. I did not use this type in this assignment, but I do see its usefulness.

2. What kinds of values did you struggle to type correctly? Are there any Typescript topics that are still confusing you?

In terms of typing values, I did not have any struggles. I found it straightforward to do (and useful). Also, there are no Typescript topics I am still confused about.

Testing

1. What was your experience writing tests? Was it boring, soothing, rewarding? How did they affect your development process?

I enjoyed writing the tests. In some instances, I wrote my code and then verified it with a test. In other instances, I wrote the test first and then wrote the code. In both cases, the tests ensured that my code worked as intended. That is, the tests aided in my development process. I had confidence that my code worked before moving on to other parts of this assignment.

2. Did your tests help you find any bugs? If so, which ones?

My tests helped figure out some issues I had with my SQL queries. For instance, in my POST requests, I sometimes forgot a field or two within the SQL queries itself. I do not believe my tests found any other bugs, but it did help me get confidence that my code does not have any major bugs in it.

3. How would you structure your testing differently in the future? What did you learn while testing?

I do not think I need to structure my testing differently in the future. I think my tests helped me confirm my code works as intended. Overall, testing during this assignment demonstrated the usefulness of testing and discovering bugs in your code while developing it (and before shipping it to somewhere or someone).

LLMs

1. Did you use LLMs to help you write your code? If yes, explain how you used them.

I used LLMs to help figure out certain syntax (and nothing else). For example, in this segment:

if("name" in req.query) { result = await db.all("SELECT * FROM authors WHERE name LIKE '%' || ? || '%'", [req.query.name]); }

I originally had req.query.hasOwnProperty("name") because that is how I did it in CS 375. However, it seemed like that was not the correct syntax in this case, so I asked an LLM for help. I also needed help figuring out the SQL query that matched all rows in authors where the name contained the req.query.name string. It would have taken me a long time to figure that out on my own.

2. If you used LLMs, reflect on how they changed your experience of coding. Did they make it more or less fun? Did they save you time? How do you think they affected what you learned from this assignment?

My usage of LLMs in this assignment did not make it more or less fun. It did save me time figuring out syntax issues and complex statements (like the SQL query above). I do not believe my usage of LLMs affected what I learned from this assignment. I wrote the majority of the code for this assignment (backend, endpoints, and tests) without LLMs.

Home