pnwt.bid
Published on

Why should we refactor / clean code?

Authors

Follow the Thai version here.

Overview

The main purpose of code refactoring is to reduce technical debt, thereby improving code quality with easier maintenance, cleanliness, readability, and reduced development costs. Let's explore the factors:

Writing clean code is beneficial for oneself and colleagues.

If we encounter a huge block of code, thousands of lines long, or a method spanning 400-500 lines, it may take us longer to refactor. If parts can be separated, they should be separated; if they can be combined, they should be combined.

Avoid repetition and overlap; it's not beneficial.

Often, we might encounter duplicated code. This means that if we need to modify that code or feature, we'll have to make changes in multiple places, causing unnecessary delays in development.

Do it right the first time; don't be lazy.

Code should be divided into smaller parts as much as possible. Don't mix unrelated things together to avoid unintended side effects. Each class or method should serve a single purpose to reduce complexity and redundancy.

Clean code is easier and cheaper to maintain!

Thank you for watching!