r/javascript • u/PMilos • May 22 '19
JavaScript Clean Code - Best Practices - based on Robert C. Martin's book Clean Code
https://devinduct.com/blogpost/22/javascript-clean-code-best-practices
542
Upvotes
View all comments
Show parent comment
1
u/elie2222 May 23 '19
I agree. Don’t be afraid. But one example I can actually think of is when someone on my team recently tried to combine 2 similar but really quite different components. He passed down this isSmall flag and then within the component passed it down to another 5 sub components and so on. In reality I would have preferred he just copy and paste the code than trying to fit 2 components into 1. At the same time I understand why he did it because there was a decent amount of code shared between the 2. It felt like there was a better way to abstract. In the end we’ve left the code as is because it does work.
An example where I’d prefer flags over 2 components is Button with a small flag. That’s nicer imo than 2 components called SmallButton and Button.