DEV Community

Tuan Thanh Tan
Tuan Thanh Tan

Posted on

Rewriting history in Git

Introduction

Hello everyone, my name is Dustin. Today, I wanted to talk about the experience of refactoring my entire code written in Nodejs and rewriting history in Git.

Process

To be honest, I didn't think that it would be that difficult until I broke the whole thing. I literally had to rewrite everything from scratch. I mean not everything but everything. So first off, I had to create a readPath class which mainly will get the path from main to check if it is a folder or other files: .txt, .md, or .json so that I can use different method for different file types. After that, I need a produceFile class, which is going to help me in creating html file and a produceFolder class, which just helps me create a folder in the root directory where the user is sitting at.

Comparison

Before using classes
I will have around 6 files in my helpers folder here

After using classes
I just have 3 classes here

And the code is well organized and easy to read even if for beginners who are used to object-oriented programming.

Achievement

Thanks to the assignment, I got a chance to learn more about rebasing, amending as well as using classes in Javascript.

Commit in git

3fcb0c88

Top comments (0)