Home
CS 478 HW 1 Reflection
Coding
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.
This assignment took me about 3 hours. I didn’t find it particularly difficult due to my prior express experience, it was just a lot of little things to implement.
Where did you spend the most time? Fixing configuration, figuring out Typescript, designing your API, writing tests, debugging your request handlers, etc.?
I’d say roughly half the time was implementation, and the other half was testing. The newest thing for me was validation, & just thinking about all the invalid cases to account for in the API request handlers
What did you struggle with the most? What would’ve improved your experience on this assignment?
As mentioned, the biggest thing with this assignment, and in general when I develop APIs, is accounting for all the possible inputs. The valid inputs are fairly straightforward, but it can seem daunting thinking about all the possible ways in which a user can pass incorrect or malformed information to the API. One thing that I think would’ve made this easier would be if the test cases were provided, and I just needed to code around that provided test suite. This way, I know exactly which invalid cases to expect
Typescript
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?
One error it didn’t prevent was that I had a database query, and I was assuming the response was of type `number`, but what the database was actually returning was of type `[ { MAX(id) } ]`. Because of this, the code was leading me to believe I was working with a number, but when I logged, I found out I was actually dealing with an object. Conversely, when I changed the type to `[ { MAX(id) } ]`, the now object that I was passing to the insertion query underlined red, and I realized I needed to extract the `MAX(id)` value to fix the bug.
What kinds of values did you struggle to type correctly? Are there any Typescript topics that are still confusing you?
The hardest typing for me was the database responses. When you query for one item, it doesn’t just return that item, it returns a single element array containing the item. And then when you query for column MAX, instead of returning an integer, it returns `[ { MAX(column_name) } ]`. And then when querying on the test side, when a query found nothing instead of returning [], it returned undefined. I think the <> part that interprets the return type has something to do with all these discrepancies, and I’m still not sure how you’re able to determine what’s a value type to put in there. Like, I put for one, and it returned a value that certainly was not a number
Testing
What was your experience writing tests? Was it boring, soothing, rewarding? How did they affect your development process?
I found the process to be on the more tedious and boring side. I generally don’t like testing, but I recognize it’s a necessary evil in software development. I’d say they did give me peace of mind though. By the end I’m confident I’ve covered all the necessary functionality.
Did your tests help you find any bugs? If so, which ones?
Yeah, I’d say I found 2 or 3 bugs along the way. The most notable one involved the database returning from a query the value `[ { MAX(id) } ]` where I was expecting just an integer returned, so I was adding that object to 1, and then passing this new value into a new query. I found this because one of my routes was returning 500 when it was supposed to be returning 200. I also found a bug where the server crashed rather than returning 400 when req.body is not provided.
How would you structure your testing differently in the future? What did you learn while testing?
LLMs
Did you use LLMs to help you write your code? If yes, explain how you used them.
No, I didn’t use any LLMs. I know some classes are allowing partial use of LLMs but I’m honestly not comfortable taking any risk with academic dishonesty, so I’m going to steer clear until admins clearly state these tools are allowed in their entirety.
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?
N/A