4 ms·
If you feel confident refactoring some code then you have been able to read and understand it easily. If you can read and understand it easily then it’s good co
by sjducb 3y ago
If you feel confident refactoring some code then you have been able to read and understand it easily. If you can read and understand it easily then it’s good code, leave it alone.
- IshKebab 3y ago"Never refactor"? Great advice
- sjducb 3y agoThat’s not what I said. If the code is confusing then absolutely refactor it. There’s 3 levels of understanding DRY 1 programmer is unaware of DRY 2 programmer sees how much simpler code is when you reduce duplication 3 programmer sees how DRY can sometimes cause it’s own problems. A good clue is that if the cyclomatic complexity of the system goes up when you DRY then you shouldn’t DRY. For example if the new single method is now full of if statements then you’re creating problems. Another clue is if you’ve just coupled things that shouldn’t be coupled. Low cyclomatic complexity and coupling of components is much much more important than having a DRY code base.