DEV Community

Cover image for Refactoring the SSG Convertor
Japneet Singh
Japneet Singh

Posted on

2

Refactoring the SSG Convertor

Introduction

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.

Improvements

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

Conclusion

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

Sentry blog image

The countdown to March 31 is on.

Make the switch from app center suck less with Sentry.

Read more

Top comments (0)

Billboard image

πŸ“Š A side-by-side product comparison between Sentry and Crashlytics

A free guide pointing out the differences between Sentry and Crashlytics, that’s it. See which is best for your mobile crash reporting needs.

See Comparison

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay