Working In Open Source
Tags: opensource, javascript, github, html
Published: 2021-09-17 16:15:11

__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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ogwzan4cqxl29774w60.png)
 

##Issues
####Here are some issues I found in my partner's code:
+ [Issue #1](https://github.com/dhillonks/cli-ssg/issues/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](https://github.com/dhillonks/cli-ssg/issues/2) There is a __deletable statement__ in the code. This statement can be deleted since the output path is set by default.
+ [Issue #3](https://github.com/dhillonks/cli-ssg/issues/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](https://github.com/dhillonks/cli-ssg/issues/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](https://github.com/DerekJxy/My-First-SSG/issues/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](https://github.com/DerekJxy/My-First-SSG/issues/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](https://github.com/DerekJxy/My-First-SSG/issues/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](https://github.com/DerekJxy/My-First-SSG/issues/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](https://github.com/DerekJxy/My-First-SSG/issues/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](https://github.com/DerekJxy/My-First-SSG/issues/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](https://github.com/DerekJxy/My-First-SSG/issues/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](https://github.com/DerekJxy/My-First-SSG/issues/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](https://github.com/DerekJxy/My-First-SSG/issues/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](https://github.com/DerekJxy/My-First-SSG/Issues/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]