THE SECRET RELIGION OF THE DEVELOPERS

🙌 REFACTORISM 🙌

Oren Aviad
AT&T Israel Tech Blog
2 min readJun 10, 2020

--

Photo on aleteia.org

Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code, yet improves its internal structure.

— Martin Fowler

As far as I remember, I considered myself as a refactorian (a developer who believes in refactorism). Actually, it took me several years to get here. I arrived after hours and days of refactoring legacy code, refactoring workshops and pair programming with some of the best refactorians I had had the pleasure of working with. I finally left behind my annoying fear of “it’s gonna blow” that every developer feels when starting to refactor.

The excitement of transforming spaghetti code into clean code without changing its functionality, playing with all the moving parts all together until everything fits in like magic, is something that always motivated me. I won’t lie to you — refactoring is hard work, however, it’s definitely pays off.

Photo by Cristian Escobar on Unsplash

If It Ain’t Broke, Don’t Fix It.

— Anonymous Loser 😜

When do you need to refactor your code?

Rule #1:

You don’t decide to refactor, you refactor because you want to do something else and refactoring helps you to do it.

Rule #2:

The first time you do something, you just do it. The second time you do something similar, you wince at the duplication, but you do the duplicate thing anyway. The third time you do something similar, you refactor.

— Don Roberts

Why is refactoring important?

  • Makes code more readable, easier to understand
  • Cleans up code and makes it tidier
  • Makes code more maintainable
  • Makes it easier to add new features
  • Removes redundant, unused code and comments
  • Improves performance
  • Makes code more generic
  • Keeps code DRY (Don’t Repeat Yourself)
  • Creates reusable code
  • Better class and function cohesion
  • Makes your code testable

Some Tips before you start…

  1. Do it gradually!.
  2. Always start from green ✅ (test passing) and end in green ✅. Otherwise, you’re not refactoring.
  3. If it’s not going well, take a deep breath, roll back your changes and start over.

Now, if you are a true believer 🙏, start refactoring and happy coding!

--

--