DEV Community

Shannon Crabill
Shannon Crabill

Posted on

How do you refactor personal projects?

Perhaps a better question is do you refactor personal projects?

I can see both sides of this.

Refactoring a personal project to incorporate new functionality is a good way to show off new skills. On the flip side, learning new skills may be a better use of your time.

Do you ever go back and rework old projects? What do you look for when refactoring?

Top comments (16)

Collapse
 
ravavyr profile image
Ravavyr

I mostly refactor things if i decide to go back and add a new feature or fix a bug i found. It usually goes something like "who wrote that crap? oh, right, me...i need to fix that" and then i spend two days cleaning stuff up and then finally adding the new feature :)

Collapse
 
scrabill profile image
Shannon Crabill

Lol, I can relate to "who wrote this crap?"

Collapse
 
eranelbaz profile image
eranelbaz

I do refactor my project,
most the refactor I do is when I need to add new features and I see the code that integrate with my new feature and I understand that my "now" knowledge is better than what I had so I do a little refactor,
What that helps my do all my refactor is thick layer of integration tests that tells me if I broke something

And I'm writing a new blog post about a half year refactor I did in one of my team products

Collapse
 
__orderandchaos profile image
Order & Chaos Creative

Refactoring a project is learning a new skill.

Collapse
 
scrabill profile image
Shannon Crabill

Refactoring a project is a skill in its self? Or to refactor means you've learned new skills?

Collapse
 
__orderandchaos profile image
Order & Chaos Creative

Well, both of course.

I get tired of the argument that "you ain't gonna need it".

It's important that we always refactor our code. Even if we never touch it again, the process itself is the most important part.

The skills we pick up as we refactor our code makes us more efficient at spotting opportunities to refactor and at quicker at implementing the changes.

Once you start refactoring everything you start to notice the consistencies in your codebase then you can decide whether or not it's worth abstracting them away.

Sure sometimes you can take an abstraction too far but you'll never know whether it's worth it or not without a lot of practice and experience.

The only way to get that is to refactor everything all the time.

Collapse
 
tiso profile image
tiso

I do, for one of two reasons:

  1. I want to upgrade code to my new/better skills.
  2. I want to add some new feature (move project forward). You know, I have lot of projects in "it does something i want, but i have lot of features in mind to add there" state. Some of them i didn't touched for years. Now i have some time to move them forward - something like End of Year Resolution.
Collapse
 
zakwillis profile image
zakwillis

Yes and no.
I only refractor when;

  • something I did before needs enhancing and it becomes obvious it has become too complicated to extend/understand.
  • I find myself repeating the same code. Some code will move to a utilities library or generic.

Often, it is more that if something wasn't developed fully, it is new code, so little refactoring occurs.

It is definitely the case there are some awful parts to my code, but typically they are fire and forget.

Collapse
 
sylwiavargas profile image
Sylwia Vargas

I decided to refactor my side project from April from bootcamp. It was the first time I did anything with Rails and CSS and it shows - CSS is a mess. I genuinely like the project so decided to give it a new life. I wrote a plan for myself and wrote about it here:
dev.to/sylwiavargas/refactoring-my...

I’ve been coding 10-75 minutes a day this holiday break. I see I’m learning a lot, also because I give myself space to go down the rabbit hole of docs and stack overflow threads :)

Collapse
 
get_hariharan profile image
Hari Haran😎

When I initially wrote my library to access StackExchange Api's, it was just working and the code was super trash. I again refactored it in a much better way. Have a look here

github.com/gethari/StackExchange.NET

Collapse
 
larswww profile image
larswww

When I want to add something new to my project, I take a close look at everything on display to the user, and focus on making sure what’s already there is working as well as it could.

I usually find that there’s stuff I’ve already done, which I haven’t done as well as I could :)

Collapse
 
aolivier profile image
Adrien

I do refactor my projects, principally because if you learn something new every day, some new framework or some new pattern and refactor your personal project is, I think, a great way to improve your understanding on those.

Collapse
 
scrabill profile image
Shannon Crabill

Agreed!

Collapse
 
dominicduffin1 profile image
Dominic Duffin

I haven't yet, although there are a few things I would go back and refactor if I was going to work on them again.