Friday 15 October 2021

OSD600 - Lab 5 Refactoring CMD-SSG

 Introduction

This week we are refactoring our beloved open source SSG program  We learned to use the git commands git rebase as well as git commit --amend to rewrite history on a branch and to add/change our git message as well as the command git merge in the end.  Refactoring is a technique for improving the structure and maintainability of your code without altering its behaviour. I made several refactoring changes.

Refactoring

 1. created a new helper.js file to add all functionality of generating .html from .txt and .md files

 2. exported the functions checkInput, convertToHtml, displayError as new or existing functions to make the code cleaner.  "checkInput" does input checking of what the user enters, "displayError" is a function specific to displaying error codes and convertToHtml is an existing function to generate the final html files.  

 3. refactor some variables names that are not up to standard like test1 and test2 such as the following image.


Additions

4. I added support for output folder command with -o or --output as well for better use.

5. added a config.json test file and made changes to README.md

Time for Some Squashing

git rebase main -i

and...

git commit --amend

then... the commit message 6a0e543

 

* extracted helper functions to new file to make code more modular

* Extract error codes into single use function

* Renamed test and test2 variables

* refactor/fix code for output

Ta Da... git push origin main

Conclusion

This week has been a truly busy week for me, but I did not overlook the fact that what I learned here this week will change the way I view, code or experience Git and Github.  I no longer feel like a novice at Git or have began to shed my fear of it.  I still make mistakes, but I know how to fix things now.

Thanks for Reading guys.

No comments:

Post a Comment

What I learned from Project 1 of Udacity's Data Science with Python bootcamp

Introduction As part of the project I completed successfully, I used SQL to explore a database related to movie rentals. SQL queries was ran...