11. Do Not Repeat Yourself
Code duplication grows like weeds and breeds bugs. Extract shared logic into one configurable place — but don't abstract too early or in the wrong way.

You're building a new page, component, or piece of logic—and it looks a lot like something you've already written. Copying it seems like the easiest thing to do. Tweak a few lines, and you're done.
Until you need to make a change… and realize you have to update it in several places. Or worse: you forget a few, and suddenly your client or end user is unhappy because something isn't working properly.
Code duplication might seem harmless. You quickly copy a snippet into another component or function. But those little duplicates grow like weeds. Soon, you update one place… and forget the other three.
That's why one of the golden rules in software development is: "Don't Repeat Yourself" – often shortened to DRY (though I'm not a big fan of abbreviations 😉).
This principle isn't just about writing fewer lines of code. It's about maintainability, clarity, and scalability. By avoiding repetition, you reduce bugs and bring peace to your codebase.
If you find yourself using the same logic or component in multiple places, turn it into a shared utility or component. Store it in a central location, make it configurable through parameters or props, and use it everywhere. Besides reducing code duplication, it brings real structural benefits:
- ✅ One place to make changes
- ✅ No risky find-and-replace
- ✅ More consistency and peace of mind
Don't overdo it
Sometimes, bits of code look similar but differ in subtle ways. Abstracting too early or in the wrong way often leads to overly generic helper functions that no one understands.
💡 If you can only spot the duplication after reading both versions carefully, it might not be time to abstract yet.
In closing
"Don't Repeat Yourself" isn't a dogma—it's a guiding principle. Watch for repetition, think critically, and choose the right moment to extract shared logic. The less you have to remember, the more brain space you can use for what really matters: building great software.
🚀 Looking for a seasoned Frontend Lead who brings structure, quality, and calm to your codebase? Send me a message—I'd love to help.


