Here’s your revised markdown with grammar and spelling corrections:
Introduction
This week, in our open-source course at Seneca, we were asked to refactor our code for a command-line tool. I have been working on Resume Enhancer for a while now, adding new features every week, and now it's time to reduce technical debt. Technical debt is the result of quickly extending software without managing the quality of the code.
My task for this week was to make the code for Resume Enhancer more readable by performing the following tasks: extracting functions, extracting classes, renaming variables, and splitting code into different files.
The Process
I started by pulling the latest changes from origin/main
using git pull origin main
. Next, I checked out a new branch from main to refactor the code using git checkout -b refactoring
.
After that, I began to refactor my code. I made the following changes:
1) I extracted the argument parsing logic into a separate function parse_arguments()
.
2) I renamed a few variables like args
-> cli_arguments
, resume_content
-> parsed_resume_content
, and job_description
-> parsed_job_description
.
3) I moved get_help()
and usage_error()
from resume_enhancer.py
to utils.py
.
The next step was to merge this branch into main using squashing. During the refactoring process, I made three commits, and before merging these commits, I was asked to squash all of them into a single commit. I used git rebase main -i
, which opened an editor with all those commit messages, and I needed to specify what to do with each commit. I squashed the last two commits into the first commit and closed the editor. I realized that after performing the squash, I only had one commit, and the message wasn’t descriptive of what the commit was for. I did git commit --amend
, which allowed me to modify the previous commit and opened an editor for the same. I updated the commit message and exited the editor. Now that the refactoring branch was complete, we were ready to merge it into the main branch:
git checkout main
# We should be able to do a simple fast-forward merge
git merge --ff-only refactoring
git push origin main
After merging, I pushed these changes to origin/main
.
Final Thoughts
In conclusion, I developed a clearer understanding of how git rebase
functions and how it can be applied to streamline commit histories, which will be valuable for future projects.
Top comments (0)