Homework 2 Reflection

Node

  1. One change I had to make was the path for the database.db file since it was originally pointing to back/, but I needed it to point to the root directory instead. I found this when working on the frontend since no books were showing up in the table. I also added support for author search so I had to modify the GET '/api/book' endpoint by adjusting the SQL query to have a condition JOIN and use LIKE for partial name matching for the author. If I could go back in time, I don't think I would change too much. There wasn't a lot of backend refactoring since most of what was changed, was because of added features. I might've thought a little nore about what other frontend features/functionality would be common to have on a site (like the search bar) and add it into the backend from the start.
  2. For adding the books and authors, I only used server-side validation with Zod. One pro of server-side validation is that it is secure and prevents invalid data from going into the database. One con is that the user doesn't know if any of their input is invalid until they try to submit the form, which could be annoying if the form was really long.

React

  1. Generally, I enjoyed using React compared to plain JS DOM manipulation. At first I strugged with state management and hooks like ensuring 'useEffect' didn't cause infinite loops. I enjoyed how the UI updates automatically when a state changes instead of manually selecting and updating DOM elements. This made it a lot easier to visualize what the UI should look like based on the current state.
  2. Compared to plain JS DOM manipulation from 375, React feels a lot faster, intuitive, and structured. I prefer it because it makes it easier to reuse components and manage form data without always querying the DOM.
  3. I found using types to be pretty helpful especially when I defined the Book interface and used 'typeof' for the filter for genres. Types helped me to catch mismatches between the server and the UI early on particularly when I tried to access 'author' instead of 'author_id' in the book object. Initially, it was a little tedious to get the types exactly right, especially with 'useState' and form events, but overall it helped prevent bugs and gave me more confidence in my code.

LLMs

  1. I primiarly used LLMs to help with debugging errors. Even something as simple as when I didn't see any books in the table in the browser and used some curl requests to test the server. Ultimately, the issue was with the database.db file path in server.ts. I also used it to help style the forms to display vertically and look a little nicer. Since I'm not the most familiar with Typescript or React, it also helped me debug issues a lot faster.
  2. Using LLMs did make it more fun especially since I can ask additional questions if I'm confused about the error, want to know more, and how I can avoid it next time. I think using LLMs can help me problem solve better and prevent reoccuring errors in the future.