DEV Community

cychu42
cychu42

Posted on

The Experience Of Debugging A Project

The Background
I’m trying to make a static site generator that takes TXT files to generate HTML web pages, using JavaScript. I used Slack to see if anyone is interested in being a partner to review my project while I review their project. The person I end up working with was also making a similar tool.

The Experience of Debugging Another’s Code
The partner was using a npm package called Chalk, which I didn’t know about, and he separates his code into parts differently from me. It’s a bit difficult to understand some of the code since there was no comment, and I’m new to the npm package he was using. Because the README.md was still a work-in-progress, I needed to ask him how to use the tool directly. Overall, it’s interesting to see other people’s code because everyone code differently and know different things, and I get to learn from them when I see their code, whether it’s technique, organization, or just new tools they use.

Issues I Opened On My Partner's Project
https://github.com/SerpentBytes/siteit/issues/1
This one is about the tool showing an error when accepting a single TXT as input, but the tool runs successfully without issue.

https://github.com/SerpentBytes/siteit/issues/2
During testing, I encountered an issue where the tool always deletes the output folder after generating the output. Since the tool is supposed to delete an existing output folder and then recreate it, the code seems to execute the deletion and creation in the wrong order.

https://github.com/SerpentBytes/siteit/issues/3
This one is just a reminder about the README.md being empty and needing some instruction for potential users, as I understand it will be filled eventually. I also make a few suggestion on what to include, like mentioning Node.js as a requirement.

https://github.com/SerpentBytes/siteit/issues/4
For this issue, the tool create an output folder to place the HTML files, but it doesn’t actually place any files inside.

https://github.com/SerpentBytes/siteit/issues/5
A bug I ran into was the tool inaccurately showing an error about invalid source files (TXT) only when the output folder doesn’t exist.

https://github.com/SerpentBytes/siteit/issues/6
This issue is about a command listed by tool, but it doesn’t get recognized as one.

The Experience of Having Another Debug My Code
Well, this feels a bit anxious, as I dislike showing mistakes (while very forgiving of others making the same mistake. Ironic, I know.) However, I remind myself that people are just trying to be helpful, and it doesn’t mean anything. Typo, brain fart, and general mistakes happen to everyone.

I learned quite a bit from the person I worked with about reporting issues, as he has a very clear format for how to construct an issue to provide information when he opened issues in my project. He would list operating environment, issue, and expected behaviour as separate sections, and he also suggests penitential fixes.

Most of the work for fixing was trying to sort out how to properly delete and create folders and files. fs.promises.mkdir and fs.rmSync functions from the fs module are unfamiliar to me, so I had to look up examples and documentations to learn my way around using them. fs.rmSync was throwing error for non-existing folders or non-empty folders, so I had to use fs.access to check for existence of said folders, and use recursive option of fs.rmSync to make it delete non-empty folders. There’s one I’m planning to do but haven’t quite figure out. My partner suggested I tried to allow the user to not have to enter “node” to execute my tool from command line, which sounds cool, but I’m going work on that feature in the next iteration of my project. I fixed all of the issues he opened, saved this one.

Issues My partner Opened On My Project
https://github.com/cychu42/staticSiteCon/issues/1
This is the suggestion for not requiring the user to enter “node” to execute this tool in command line. There is quite a bit of helpful information, and I plan to add this at a later iteration of the project.

https://github.com/cychu42/staticSiteCon/issues/2
This bug is about the tool trying to process non-TXT files, which of course caused issue. I updated the code to first check for file extension by extracting it from the file name using String.slice.

https://github.com/cychu42/staticSiteCon/issues/3
My partner reported improper HTML format for missing things, like

in the HTML files. I have the tool writes those to the files in a later update.

https://github.com/cychu42/staticSiteCon/issues/4
This issue was opened when I haven’t had proper safe guard built-in in cases of invalid TXT source files. I later wrote some code to check for existence of the source and warn users about cases like a missing file or a valid path to an empty folder. It’s a mixed of using try/catch block, checking number of files using fs.readdir, and checking a flag for whether anything is processed.

https://github.com/cychu42/staticSiteCon/issues/5
My partner also reported a missing feature that would create the output folder. It should also delete an exisitng output folder and recreate it. It’s added in a later update as discussed earlier.

https://github.com/cychu42/staticSiteCon/issues/6
Lastly, this issue is just about lack of feedback to users. As mentioned earlier, I later added messages to warn about invalid source, and I also added messages to inform the user about what happens during successful executions.

Top comments (0)