Published on

Developing new functionality or refactoring

2 min read - 249 words
Authors
  • avatar
    Name
    Cédric RIBALTA
    Twitter
post image

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 :

Windows failed dialog box

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 :

Someone with glasses issue

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 :

Starship Troopers

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 Rock in a gym

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!

  1. Focus on adding functionality
  2. 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.