DEV Community

Roman Rezinkin
Roman Rezinkin

Posted on

DPS909 - Lab 5

This weeks lab included us refactoring our code. The point was not to introduce new functionality or features, but rather instead clean up our code. I chose to do three improvements to my static site generator, which included reducing code duplication through the use of functions, improving variable names, and separating the main logic from the conversion functions.

Functions - Reducing Code Duplication

This was the hardest part of the lab. I essentially had to rewrite my code, all whilst testing every code change. I was able to reduce my code duplication by a large amount. This was achieved by creating a few functions that accepted parameters from the main logic, and allowed me to create html files in a simpler way. By doing these mandatory steps, my code is a lot more readable, which means that if someone wanted to contribute to my open source project, they would have an easier time doing so.

Improving Variable Names

Some of the variable names within my code were very confusing, so much so that I had other developers ask for clarification on the meaning behind them. I took the initiative during this lab to make them more understanding.

Separating the Main Logic

In my last refactoring step, I took the chance to split my main logic code from the bulk of the other code. This means that now there are two files, one being a utility file, which contains all the functions needed to operate my static site generator, and the second being the main , which holds the argument parsing, etc.

Overall, the git rebase and squashing was pretty straight forward. Here is a link to the commit...

Discussion (0)