Lessons Learned from Cleaning Up Code

min read

At 175 words per minute.

2024-12-13 Back to posts

A clean code editor interface.

Refactoring isn't just about simplifying code; it's about making it work better.

Refactoring for Clarity: Lessons Learned from Cleaning Up Code

Refactoring code can sometimes feel like a chore, but it’s one of the most rewarding aspects of development.

Recently, I revisited code on this website and stripped away unnecessary styling and complexity.

The result? A cleaner, more maintainable codebase that’s easier to work with.

Why Refactoring Matters

Codebases naturally accumulate “cruft” over time.

It could be overly complex logic, unnecessary styling, or redundant libraries.

Taking the time to refactor is more than a best practice—it’s an investment in the long-term health of your project.

When you refactor, you’re optimizing for the future: for yourself, for your team, and for anyone else who interacts with your code.

1. Simplify for Readability

One of the main goals of refactoring React code is to make the code easier to read.

For example, I removed unnecessary classes like shadow-lg, rounded-lg, and transform from a component. (Learn about shadows and rounded corners in TailwindCSS)

A simple design allows developers to focus on what’s important without distractions.

2. Avoid Over-Engineering

Sometimes we add abstractions that feel clever but are ultimately overkill.

During the cleanup, I noticed parts of the code that included excessive animations and transitions. These weren’t adding value.

Refactoring Guru explains this well: refactoring should reduce complexity while maintaining or improving functionality.

3. Stay Consistent

One unexpected challenge was case sensitivity in file imports. Small inconsistencies like GitHubButton.tsx vs. GithubButton.tsx caused errors in some environments.

It still ran but VS Code was not happy with me!

Refactoring gave me the opportunity to standardize naming conventions across the project.

Consistency is one of the hallmarks of a professional codebase. It makes everything from debugging to onboarding significantly easier.

Here I refactored the button linking to the github repo into a seperate file:

import React from "react";

export default function GithubButton() {
    return (
        <button>
            <a
            href="https://github.com/Sieep-Coding/sieep-coding.github.io"
            className="flex items-center space-x-2"
            >
                <i className="fab fa-github self-center hover:text-accent dark:hover:text-dk-accent text-2xl"></i>
            </a>
        </button>
    )
}

Then I can use it elsewhere in a straightforward manner:

...
<li className="p-4 flex flex-row items-center justify-evenly">
    <ToggleDarkMode />
    <Search posts={posts} />
    <GithubButton /> // Using refactored code here!
</li>
...

Conclusion

Refactoring isn’t just about making the code prettier—it’s about making it work better.

So, the next time you’re looking at your code and thinking, “This works, why bother?”—remember this:

refactoring isn’t a chore; it’s a craft.

Written By Nick Stambaugh

Nick Stambaugh

Nick Stambaugh

Full Stack Engineer

Full Stack & Enterprise Application Engineer

Recent Posts

Thoughts on Pop!_OS

My thoughts on the Pop!_OS, as an engineer and gamer.

2025-03-31

Read more →

#Linux #OS #Tech

Why Micromanagement Kills Innovation

Micromanagement of workers, especially software engineers, is detrimental to innovation.

2025-03-19

Read more →

#Workplace #Leadership #Business

Adding Music To My Raylib App

Adding audio to a C application is easy with raylib!

2025-03-13

Read more →

#C #raylib #Coding #Low-Level Development #Tech #Music

Why I Love Houston As A Michigander

Houston is an amazing city to explore with a wide variety of interesting activities, culture, and food.

2025-02-22

Read more →

#Houston #Travel

What I've Learned about LINQ and MVC

An example of why I'm starting to love C# more than Go.

2025-1-19

Read more →

C# #.NET #Coding #Tech

[PART 1] Creating A SQL-Like Language in C#

Part 1 of creating a SQL-like language in C# for fun.

2025-1-3

Read more →

C# #.NET #Coding #Tech