DEV Community

Andrew Tassone
Andrew Tassone

Posted on

Refactoring The Great Site Generator

This week, I focused on refactoring this project using git rebase to rewrite history on a branch for my first time. I also learned how to use git commit --amend to change the information in my commit.

I wanted to reduce redundancy in my code so I created a function called readFolder() for reading folders. I also combined readMarkdownFile() into readFile(). This supports both file types of either .txt or .md.

Lastly, I separated these functions into a new class called Reading. I then placed the class into its own reading.h file. I broke it a few times during this process, usually just forgetting a brace somewhere.

Using the interactive vim to edit commits was new to me. Ive used command line editors before but not very much. At first, I made a few mistakes by accidentally adding too many spaces between the commit ID and action. I received a few errors but figured it out eventually!

Changing git history was interesting and a useful thing to learn when cleaning up code and changing commits. It was confusing to do at first but I will keep practicing. I hope to use it again in the future!

Discussion (0)