Homework 2 Reflection

Node

1. Keep track of any changes you made to your back end as you implemented your front end. What changes did you need to make and why? If you could go back in time, is there anything you would change about the way you approached making your back end for HW1?

I made a few minor changes to my back end as I implemented my front end related to error handling. Previously, users could create an author with a blank name and a book with a blank title. Now, both of those situations throw a 400 error. I added two tests for these scenarios.

Additionally, I also added error messages to situations where I previously didn't have any. For instance, if you tried to get an author by id and there was no author with the specified id then the server would just return a 404 error. Now, I included more descriptive error messages (such as "Author with id " + params.id + " is not found.").

Apart from that, I made minor changes here and there. For instance, I changed the API routes from /author to /api/author and /book to /api/book. This also required changing the API routes in all of my tests.

Overall, there isn't anything I would change in how I approached the backend in Homework 1. I believe I did a pretty good job with it.

2. When adding books and authors, did you only use server-side validation, or did you also use client-side validation? What are the pros/cons of making either choice?

I only used server-side validation. I did not use client-side validation at all.

Using server-side validation has several benefits. The server has access to databases, external APIs, and other resources, allowing the server to validate many things that wouldn't be possible on the client side (such as a duplicate username). However, there are also several concerns. If all simple validation was handled on the server side, there may be several unnecessary server calls (increased server load). Additionally, feedback regarding the user's inputs is delayed, resulting in a worser user experience.

Client-side validation has several benefits. It offers users immediate feedback (better user experience). It also reduces the number of server calls users make since they don't need to submit anything to the server to realize there's an issue with their inputs. However, there are also several concerns. Users can edit the Javascript of webpages, so important validation should not be handled on the client-side. And some validation is not possible without making a server call (such as a duplicate username).

React

1. What was your general experience using React? What did you struggle with? What did you enjoy?

Overall, I enjoyed using React. I find it easier to look at and separate different sections (components) of a webpage compared to plain HTML/CSS/JavaScript. Additionally, I found it easier to keep track of variable values (states) as things get manipulated.

Since I have previous experience with React, I did not struggle with it. Admittedly, I still believe the material in this class is helping me understand React better even though I worked with React before during my co-ops. It's sometimes hard to sit down and look at the very basics of things when you're trying to complete tasks at work.

2. Compare and contrast writing React versus writing plain JS DOM manipulation code as you did in CS375. How was your experience different? Which do you prefer and why?

To update the DOM using plain JavaScript, I needed to find specific elements on the webpage and modify its internal values. When certain situations occurred, I would need to write code to update the DOM. To update the DOM using React, you modify certain state variables. Then, React automatically updates the associated component on the webpage. Overall, I prefer using React because components get updated automatically instead of me having to query for specific elements. I find React easier and neater to work with. But, in the end, I'm willing to work with either

3. What was your experience using types with the front-end? Did they catch any bugs? Did you struggle to type things correctly? Did they feel helpful, useless, tedious?

Overall, using types with the front-end was straightforward. I do not believe TypeScript caught any bugs, but it did seem to miss one. The only time I messed up the typing of something was with the author id field for books. In the front-end, the state variable is a string. But, the back-end expects a number. So, I needed to cast it from a string to a number when sending the book data from the front-end to the back-end. I only realized it was an issue when it errored out while I was testing in the front-end. TypeScript did not tell me anything about this issue.

I did not struggle to type anything correctly. It was easy for me to recognize what the type of something should be. Overall, I found the process to be helpful. It's good to know what type of data fields is being sent back and forth. I don't find it useless or tedious. I find it useful overall.

LLMs

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

For this assignment, I did not need to use LLMs. I found that the code we wrote for the class activities were enough to complete this assignment.

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?

I did not use LLMs for this assignment.

Home