- Published on
Developing new functionality or refactoring
- Authors
- Name
- Cédric RIBALTA

Introduction :
As developers, we're tempted to optimize existing code while adding new features.
However, this can be counterproductive.
In this article, we'll look at why it's best to separate these two tasks.
Refactoring : Refactoring is the practice of improving existing code without modifying its behavior.
The risks :
1. Bug risks :

When you add a new feature, you're already manipulating code with a risk of introducing bugs. With parallel refactoring, you increase the chances of introducing bugs, by making it difficult to identify their origin.
2. Traceability and easy-to-read :

By interweaving your changes, it becomes harder to understand what's refactoring and what's new functionality. This can also complicate code review.
3. Conflicts :

Refactoring often involves several files or several pieces of code.
This increases the risk of conflicts when merging (if you're working with other devs on the same project, of course).
And that can lead to delays and added complexity.
4. Focus and prioritization :

The development of a new feature must meet the needs of users.
By refactoring at the same time, you diminish your focus on this objective, and run the risk of satisfying neither.
Best practices :
Separate these tasks!
- Focus on adding functionality
- Refactor the code into another task
This method will improve the quality of your code.
Traceability will be clearer.
And your development will be much more relaxed.