It has been a very productive yet not productive week for me. I was able to dedicate most of my week for this project yet also had a lot of hiccups along the way since it has been a while since I’ve worked on full stack project. I think total I have spent more than 30 hours this week to get my wheels rolling. I think it took me a few hours doing actual coding and most of the time debugging.
There were many types of obstacles I’ve faced while coding this week. One of them was syntax. Since I’ve been trying to learn and juggle 3 different programming languages on weekly basis, it was very confusing to switch gears and code in another language. I spent a lot of time searching for syntax and notations, especially for things like arrow notations with no parameters, React concepts and notations for state handling and rendering, and Mongoose functions. I didn’t find an easy way to do this, just experimenting dividing my days of the week to focus on one language / project a day instead of trying to do little bit of each everyday. And also lots and lots of googling. However, it was no biggie. It was something that I could find answers right away and fix.
The harder part was actual code debugging when I have no idea what has gone wrong. Most of the my time I have spent this week was trying to fix up the bug that form was not updating with everything in the front end validation and backend API setup. Since there are so many parts involved in this one bug, debugging was a pain. There are many types of debugging methods out there and the main debugging method I’ve used were incremental inspection, logging, and asking for help.
When I run into problem, I first identify the problem by checking if there are error messages either on terminal or console. Then I would follow the indicated line back to the code to backtrack and find the piece of code that creates the problem. When there are no errors, I check in increments. Is my form able to render the previous data? Check. Am I able to edit the form? Check. Is the submit button working? Check. Is it sending information to the backend? Yes. Is the backend receiving the information? No. Then I eliminate all the front end form related code from the source of problems. Then I would break down again and check in backend whether route is correctly defined, if reducer is set up correctly, etc. It may be possible that I’m not able to fix the bug but at least I can identify it.
Accompanying the method above, what I like to do is log EVERYTHING. As soon as I find out the chunk of the code that’s not working, I’ll add print statements to log every step on the console. Some problems are not so obvious when I skim through the code. Everything seems to make sense and logically flow well. But once I start logging everything, I’m able to find out if there are some connections or data missing. I personally find this method the easiest and most useful tool when debugging.
With the two methods above, I was able to identify where I got stuck but I didn’t manage to fix it. I was just learning and using some libraries for the first time and I did not grasp the concepts fully. Even with lots of googling and trying, I found no solution. So what I did was I asked for help from my teammates. After all it is a group project right? Since I have teammates who are working on the same project, I have people who are familiar with the tools and languages to get advice on. Thus I just reached out for help and luckily one of my teammates has more experience with the tools and was able to debug and explain to me what the problem was within few hours. It turns out I was trying to solve the problem by fixing another section. Sometimes it is easy to get stuck in one particular zone and not able to see the big picture of suspect of other parts that were problematic. You might feel vulnerable asking someone for help but sometimes it is much more efficient to do so since the problem I spent days to debug was solved was fixed within hours with another set of eyes.
Debugging is a long patience game that requires a keen eye for details. There are many ways to approach and there’s no right way. I think it’s best to have a set of go-to approaches that works for you to help move forward, whether it is coding or any other project in life you work on.