DEV Community

loading...

Discussion on: When Code Duplication is the Right Answer w/ Sandi Metz

Collapse
msoedov profile image
Alex Miasoiedov • Edited

In Soap/Micro service architecture I have an empirical rule:

0) Duplication within the same codebase is bad unless it serves purpose of better readability.
1) Duplicating the same utility/stateless code twice is not a crime in separate projects.
2) Making some piece of code to be generic to fit only 2 usages in different micro services/projects is over engineering and usually a bad idea
3) Duplicating 3 times (across diff projects) is still not bad but probably It's time to reconcile why this is happening and mark it as a refactoring candidate.

Collapse
niko profile image
Niko 👩🏾‍💻 Author

Thanks for sharing, that makes a lot of sense! I'm going to add this to my jr dev notebook. I'm just now coming to terms that duplication isn't always the bad guy as I was taught in school.

Forem Open with the Forem app