DEV Community

Discussion on: Refactoring old code vs Rewriting everything for long-term?

Collapse
 
johannestegner profile image
Johannes

I would personally say: Start with writing the tests. That way you can make sure that the current code is working as intended. After that, take a long look at the "logic" and see if it would actually be worth to rewrite, if it's a short process to write a new version, branch out and do it! If it would take a long time, it depends much on the time you actually have to do it. If you are allowed to rewrite it even if it takes time, I'd go on with a rewrite, but else, leave it.

It's hard to give much advice as we don't know much about your position, if you have an annoying lead or boss standing behind your back yelling that they want that new feature a week ago, you might just want to patch it.

Collapse
 
johannestegner profile image
Johannes

Even if you don't rewrite it, create the tests, testing is great, testing is awesome, you should always write tests! ;D

Collapse
 
anduser96 profile image
Andrei Gatej

Thank you! I will definitely follow your advice.

I’ve heard a lot about testing and its practices, but I’ve never actually written a single test.

Now, because the project I’m working on became pretty complex, I can see how writing tests would make my life easier.