DEV Community

Cover image for Working In Open Source
DerekJxy
DerekJxy

Posted on

Working In Open Source

In order to make our code of Static Site Generator better, we are required to share our code to a partner and try to find out some issues that can make their original code better. And this is the main point that we have Lab 1 in OSD600.

The partner I found was Kunwarvir. I had never met my partner Kunwarvir before. And we just team up randomly. However, although we haven't met each other before, we both treat this sharing code behavior seriously.
After communicated with Kunwarvir, we both started to check our each other's code.

Interesting Stuff

This is the first time that I tried to improve other's code by my own knowledge. I've never thought that I can help people improve their code because I always think that what I known are limited and basic. However, through this Lab 1, sharing code with my partner, I learned something. I learned that there are no perfect code ever, even some beginners can help those experienced programers improve their code. I can help people improve their code as well!

Honestly, the first time I got my partner Kunwarvir's code, I was soooo confused. I felt like there is no way I can help them to improve their code base on my knowledge even though we built the code in the same language -- JavaScript. And then I just told myself, just break it down step by step, make it slow.... And then I just followed the instruction that our professor provided, and check the code step by step. And finally, I found a few issues that can help my partner improve their code! That was amazing to me! And when it comes to the end of the checking, I realized that there are a lot of similar code in our code! And I shouldn't felt panic at the beginning!

There is one thing surprised me in my partner's code. And that is they have a personal logo when the user access their code. So whenever I run their code, it will have a logo comes up like this:
image

Issues

Here are some issues I found in my partner's code:

  • Issue #1 There are some defined variables that never used in the code. const yargs = require("yargs"); const path = require("path"); These two variables are never used in the code, so I suggested my partner to remove them.
  • Issue #2 There is a deletable statement in the code. This statement can be deleted since the output path is set by default.
  • Issue #3 I found that the code my partner shared to me would generate a weird html file. What I mean "weird" is they are trying to divide the article sentences by sentences, but not paragraphs by paragraphs. And then I suggested they write the code with my new code
  • Issue #4 Since I changed one line of code in my partner's code, they need to update another line of code as well.

Here are some issues my partner found in my code:

  • Issue #1 My Index Html is failed at (X)HTML5 validation. There a space in the name of the HTML files that my code generated.

  • Issue #2 My code would convert any type of files that the user input into a html file, which is kind of a stupid feature of my code. We're only supposed to convert .txt file into a html file.

  • Issue #3 My code would convert any type of files inside the folder that the user input into a html file. This is a nonsense feature at all. My code should only supposed to work when it comes to .txt file.

  • Issue #4 My code set that all the html files generated will place into ./dist folder by default. And it doesn't allow any other save path.

  • Issue #5 I didn't have a clear declaration in my README file. And that made a misunderstanding for my partner to access my code.

Update

After reviewing the issues that my partner found in my code. I realized that those are simple and stupid mistakes!

  • For the Issue #1, the main reason that my Index Html is failed at (X)HTML5 validation is my code generated some html files that with blank space in their name. Therefore I update my code to generate html files that without spaces by using the code let validFname = fname.split(' ').join('');.
  • For the Issue #2, I update my code to check the file type fileType = argv.input.split('.').pop(); if(fileType == 'txt'){...} before doing anything.
  • Same for the Issue #3 I update my code to check the file type inside the folder fileType = file.split('.').pop(); if(fileType == 'txt'){...} then convert the files to html files.
  • For Issue #4, I'm not going to fix it right now since it's an optional feature. And there is no harm to force the user save the output html files into a specific folder.
  • And finally about issue #5, I updated my README file so that any new users could run my code easily and correctly.

I know there are more issues in my code that need improvement. And I will try my best to make it better!

Links

Link to my repo: [https://github.com/DerekJxy/My-First-SSG]
Link to Kunwarvir repo: [https://github.com/dhillonks/cli-ssg]

Top comments (1)

Collapse
 
thomasbnt profile image
Thomas Bnt ☕

Good job with Open source repositorys 😎😎