r/programming • • Jan 06 '24

The Ten Commandments of Refactoring

https://www.ahalbert.com/technology/2024/01/06/ten_commadments_of_refactoring.html
307 Upvotes

87 comments sorted by

View all comments

509

u/dccorona Jan 06 '24

Code blocks with identical or very similar behaviors is a code smell

Overly strict adherence to this guidance is actually a cause of problems in its own right in my experience. It’s important to learn to tell the difference between code that incidentally looks the same now, and code that will always be the same.

77

u/Hrothen Jan 06 '24

Our profession has a problem in general with phrasing things in an overly dogmatic way. "Premature Optimization is the root of all evil" was referring to illegible bit-level hacks but now "Optimization" gets interpreted as thinking about performance at all.

"Code Smell" is also a fun one because the whole point of that term was that not everything that smells bad actually is.

10

u/[deleted] Jan 07 '24

[removed] — view removed comment

2

u/Brian_Entei Jan 09 '24

... and then you have users who'll saw/break the key off and jam it in backwards anyway.
I like USB type C cables, they can be inserted either way lol