DEV Community

Cover image for Refactoring the SSG Convertor
Japneet Singh
Japneet Singh

Posted on

Refactoring the SSG Convertor


Hello everyone, this week we are introduced to a new topic to refactor the entire code to make it effective, shorter and understandable. Update all changes to one single commit on git.


To Begin, I started with improving indentation and some comments to make my code understandable. I have been receiving a lot of issues with the code being tough and not understandable. I certainly wanted to make the code shorter now I got the chance.

Bugs found

While refactoring the code, a lot of bugs were found. Initially, I had one function developed that looked like a mess. I tried to improve the indentation first & foremost to make it look comfy. The second step was to remove global variables. Third and mainly, Refracting of functions which took me a lot of time to cover. The extraction of function development was not necessary to run the program. But, they were prominent to improve the readability of code. In the end, I did rename some variables to make them easier to read, easier to maintain, and more modular.

Broke the program

My program did broke certain times while working on the refactoring branch. I tested code a lot of times working on extracting functions. I tried to make it common code and reduce the duplicity of code. However, it didn't go very well. I ended up breaking my code due to a lack of knowledge of working with functions in swift. I learnt that in functions with parameters those values are unchanged. The parameters are let constants that are non-convertible.

Working with git

  • creating branches to work on evolving your code
  • using git rebase to rewrite history on a branch
  • using git commit --amend to add things to a previous commit and update a commit message
  • Final Commit


Learnt how to use git rebase and git commit --amend those are very powerful commands in git to make commit modifiable and shorter.

Top comments (0)