DEV Community

DigitaBoss
DigitaBoss

Posted on • Edited on

Guys! Do you think this is correct about “Code Refactoring”

How correct is this?

Code refactoring is the process of restructuring and optimizing existing code in order to improve its quality and maintainability. It involves making changes to the codebase that do not alter its functionality, but that makes it easier to understand, maintain, and modify.

Code refactoring is important because it helps to prevent technical debt and other issues that can arise when code becomes difficult to understand or maintain. By regularly refactoring code, developers can ensure that their projects remain scalable, reliable, and easy to work on.

Was this insightful? Let me know guys! Let me see those replies

Top comments (6)

Collapse
 
ozekfave profile image
DigitaBoss • Edited

Would appreciate your thoughts on this. what else can i try?

In your opinion, would you say that to refactor a code, only two techniques actually work?

  1. Extracting code into smaller, more focused functions or methods and
  2. Removing duplicate code

Is there any other you think I could try?

Collapse
 
pratikshirsath54 profile image
Pratik Shirsath • Edited

It is better to break down the code into functions. I have used this strategy and now I am able to manage and use the same functions in other component as well. These saves my time and optimised the code.

Collapse
 
jwp profile image
John Peters

Beginners at code refactoring begin to see patterns. After a few years, they immediately know the patterns when coding. Knowing how to write code effectively is the most valuable skill a programmer has.

Collapse
 
ozekfave profile image
DigitaBoss

Thanks that was really insightful.

Can you say something about the frequency to which we refactor codes?

Collapse
 
webjose profile image
José Pablo Ramírez Vargas

Pretty much on the money. I would get rid of "and optimizing" at the beginning. Also change "and" for "or" in "understand, maintain and modify". You may be refactoring for any of those reasons. There is no requirement to fulfill all three.

Collapse
 
ozekfave profile image
DigitaBoss

I need one more help with this.

What are your opinions or suggestions on an automated test I can carry out to ensure my code isn’t broken?