DEV Community

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

Collapse
 
reisclef profile image
Richard C

I struggle with this as I like DRY concepts, but at work, I develop over the top of an already established platform with fairly strict constraints.

While they do a pretty good job in making inheritance easy, sometimes things don't quite fit the bill. This occasionally results in me having to pinch a bit of code outside the scope of what I'm doing, but not available to call independently.

I agree it's best to have a balancing act. Copying and pasting within the same OOP file is clearly not good practice. However, if re-using something that isn't easy to access, and doesn't really fit with what I need, sometimes copying a little code is the lesser of two evils.