Relief

March 11th, 2020
relief

Task Complete

On my first day in the office, back on Monday, I was given a list of tasks that could possibly take me the duration of the year to complete. I know that's not their intention, but it was a daunting list nonetheless. They had me start with some validation for a form. It turns out, this form appears everywhere on their site, on all of their articles. It serves as a lead generation tool for potential customers. The customers find the article through some type of search on Google, and if they want to learn more about the topic they are reading about, they sign up through the form. It's a fairly simple form on the outside, with a first name, last name, phone number, email, and zip code field, but the code itself was not so simple. The problem they were having was that if someone entered in a phone number like 000-000-0000, it would still take that as a valid phone number, or if they entered an email without having a period somewhere after the @ sign, it would still deem that as valid. The validation wasn't completely broken, but it wasn't good either. The other problem I realized was how the error messages occurred if there was a problem. Instead of appending some sort of message below the field or turning the input red, it would turn the input bright yellow and an alert would pop up on the screen. I don't think I've ever enjoyed an alert on a website, and I don't think anyone else does either.

alert

So, the problem was simple and it could have been a simple solution. However, the code itself was not so simple to decipher. The variables and functions were given names that made absolutely no sense whatsoever and didn't pertain to what they actually did. Also, all of the code was written with jQuery and a bunch of RegEx, 2 topics I wasn't very well versed on at all. I got to work deciphering the code, and after a few hours, I had a good understanding of how things worked in the file. From there, I just had to figure out how to get it to do what I wanted it to do, and either with jQuery or with DOM manipulation via JavaScript. Since it was already heavy on the jQuery, I decided it was a good time to sharpen those skills, and I did. I watched a series of videos by Brad Traversy, and by trial and error in the code, I actually learned a ton of jQuery, mostly pertaining to DOM manipulation. For a while, I searched for different packages that would do the validation for me, but I had no luck, and decided against it in the end. Once I figured out how to really dive into the code, things started moving in the right direction. I had issues along the way, and broke it worse than it was when I got it for a while. But I kept banging away at it, and eventually it was passable. Then came the time to get it approved, which was nerve-wracking. To have someone else review your work when it's really never been reviewed in that way before was a different feeling. But, my supervisor asked me to change a few very small things, which I did, and I was done. With that, I wrapped up my first task on the job, all the while learning some jQuery and DOM manipulation.

split

This left me with a few more hours in the day, and I needed a little direction. I know which project I will be working on next, I just have no idea in what capacity I'll be working on it. This is a project my neighbor has written entirely in React. First of all, I'm so glad to be working in React, and I feel like I'm about to learn so much. Hopefully, he will be receptive to giving me a hand understanding some things, but otherwise I'll just learn a lot by working through the project on my own. When I opened up the project, I realized it was around 2000 lines of code all in one file. I asked him politely if it would be alright to split the code into different files, corresponding to each component and function having its own file, and he was fine with that. He knew it was a mess to maintain, and he had written it in a hurry, under the pretense he would be the only one working on it. With that in mind, I totally understand why he did it that way, but I would have a really hard time working like that. Before I started to figure out exactly what I was going to be doing, I decided to clean it up. I still don't know what I'll be doing in this project, but I was able to break the code up, and I finished importing all of the files to the respective files they had components living in with just a couple of minutes left in the shift. With the day wrapping up, I was afraid to test it, knowing if something didn't work, which it inevitably would, I wouldn't be able to think about anything else the rest of the night. The first thing I'll be doing in the morning is running npm start to see how badly I broke it, but I know I can figure out what's broken, and then I can start figuring out what I'm supposed to do.

Until tomorrow!

Created by Sam Thoyre, © 2019