The following below is a reflection on my experience completing Assignment 2.
Assignment 2 required you to build on to your e-Commerce Web-site by adding a new feature where users will have to login or register to continue with their purchase of products. It also tasks you to personalize the website for each user that logins by displaying their username and in some individual requirements, keep track of how many users are logged in or how many times a user logged in. The only way for users to complete their purchase is through the login or registration page that will be made in this assignment. Other requirements also include validating that the user’s input when registering or logging in are taken into consideration. For example, if a user inputs an invalid email or a wrong password, the website should display the errors the the user.
From this assignment I learned how to access data from a server and outputting it into a webpage. I also learned how to transfer data between different pages through the use of querystrings. In this case, I had to transfer my user’s quantities over to my login or register page and finally to my invoice page. I also had to take note of removing possible errors that the user may create as they are logging in or registering. A new thing I learned in Assignment 2 that was different from Assignment 1 was the use of the functions like readFileSync() which reads the json data in my json file. Moreover the existsSync() function checks to make sure that the file to be read actually exists. The writeFileSync() is the function that updates the json data whenever the user purchases a product. In terms of validation, used regex to complete the registration requirements of Assignment 2. Besides the server.js page, I needed to update my different html pages to ensure I was pulling and outputting the correct data on the server. Overall, this Assignment 2 was yet again another humbling experience but definitely the worthwhile for anyone who wants to develop themselves as a programmer.
For Assignment 2, I did not work with a partner.
To get help, I attended Professor Port’s office hours whenever there was an announcement of such. I was able to show my code and indicate what errors I was having. If another student was getting help, it was beneficial for me as I also had similar errors as another student. Assignment 2 definitely gave me a challenge to the point that I did not even know how to start. I did the basics of building a login and register page but I did not understand how to pass data to multiple pages but the professor helped resolve this quickly. Other ways I received help was through consulting with my friends which was somewhat helpful as they were able to catch syntax errors that I could not recognize. I also read the documentation for some of the suggested code to use for this assignment. Though, both of these ways this were not as effective as getting help directly from the professor.
This assignment was much more difficult compared to Assignment 1. There were a lot more requirements like specifying how many characters a user’s password can have or if they have incorrect passwords when registering. Though there were similarities like using params.has() and params.get() to call the data and output it, there were also other things I had to keep in mind as I wrote my code. I had to ensure that the right data was being transferred between the pages and to remove any errors before reaching the invoice page. Furthermore, Assignment 2 required a lot of self-learning compared to Assignment 1. I had to learn a lot more about validation methods like regex and JavaScript String match() method or JavaScript regular expressions. Though some of the things I learned about, I did not end up using in my Assignment 2. Due to the abundant of requirements, this also meant I had a lot more errors to deal with such as not defining the right variable or calling a function. It seemed like the amount of errors I had were endless because when I fixed one, a new error would pop up in my console. Though errors also showed up in Assignment 1, it was not to the extent of how much I produced while completing Assignment 2.
If I had to estimate the percentage of time I spent on completing Assignment 2 I would split it as such:
Before I could even write code, I needed a lot of time understanding how to go about Assignment 2. I had to really understand what every line of code did which is why I spent a lot more time thinking that actually writing code. This way, I would avoid dealing with more errors that I originally have. If I had an understanding of how to approach a requirement, I would be able to write the code for it. The problem only happens when I become forgetful or actually become clueless on how to move on. As for testing and debugging, it did take just as much time as thinking about how to do something. I did have errors which would lead to more errors. I could also just control z to undo my changes but that just meant I had to start from scratch. I needed to try to do something with what I was given even if it caused me a lot more errors down the line.
For this project in particular, I think what really worked well was commenting a lot on my code. Writing these comments helped keep me on track when I took breaks in between coding. I also think choosing to keep my quantities in the querystring have both its advantages and disadvantages. The user keeps their inputs on their end but also makes it more challenging to change data on the server side. The idea of passing data between server and website proved to be extremely time consuming. I was frustrated and for the most part sleep deprived from the amount of all nighters I pulled. I can only expect the same temporary lifestyle for Assignment 3.
If I could go back in time and do things differently, I would store my json data and user inputs in the server instead of keeping the user’s inputs as a query string in the URL of the webpage. I want to really change how I approached this assignment because the way I am doing it now may pose problems regarding on how to update the quantities after a user registers for the first time. Sometimes, I have trouble really understanding the requirements of the problem and I tend to assume only to regret it later. I want to be more proactive and to ask questions if I am confused or need help. Additionally, I should also consider the due date of this project which was only a week. When I compare the amount of requirements to the amount of time we were given, I felt like I was in a pinch. There was so much requirements to complete which I do not think I could do in just a span of a week. I would have preferred if we were given more time for this assignment considering how much more Assignment 2 is demanding compared to Assignment 1. In terms of this project, it really depended on how I approached and developed my server. I am now at the point where I can still restart but I would be left behind way too far. This is why if I had the chance, I really would change the way I originally approached this assignment.