An Interest In:
Web News this Week
- March 22, 2024
- March 21, 2024
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
Code Smell 170 - Refactor with Functional Changes
Developing is great. refactoring is amazing. Don't make it at the same time
TL;DR: Don't change functionally and refactor at the same time.
Problems
Hard to review solutions
Merge Conflicts
Solutions
- Never change functionality while refactoring
Context
Sometimes we detect a refactoring is needed for further development.
We are experts at learning.
We should put our solution on hold. Work on the refactoring, and continue with our solution.
Sample Code
Wrong
factorial(n) { return n * factorial(n-1);}
Right
getFactorial(n) { return n * getFactorial(n);}// ChangegetFactorial(n) { return n * getFactorial(n-1);}// Run the testsfactorial(n) { return n * factorial(n-1);}// Rename
Detection
This is a refactoring smell.
[X] Manual
Tags
- Refactoring
Conclusion
We should use a physical token.
Either we are in the refactoring stage or the developing stage.
Disclaimer
Code Smells are just my opinion.
Credits
Photo by Dannie Jing on Unsplash
When Im studying code, refactoring leads me to higher levels of understanding that I would otherwise miss. Those who dismiss comprehension refactoring as useless fiddling with the code dont realize they never see the opportunities hidden behind the confusion.
Martin Fowler
%[https://maximilianocontieri.com/software-engineering-great-quotes]
This article is part of the CodeSmell Series.
%[https://maximilianocontieri.com/how-to-find-the-stinky-parts-of-your-code]
Original Link: https://dev.to/mcsee/code-smell-170-refactor-with-functional-changes-4e13
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To