What are your programming hot takes?

257m@lemmy.ml to Programming@programming.dev – 333 points –
876

You are viewing a single comment

Duplicate code can be a code smell, but it's far better to have the same function definition or code block appear twice in the code than extracting a function that tightly couples two components that should not be coupled at all.

See Write Everything Twice (WET) principle.

Also, some of the deep, highly abstract, functional techniques to reduce duplication are too clever for their own good. Your dev team might worship you as a programming God until someone needs to debug it. Back off on that, even if it means duplicating more code.

This. Especially if your team does not follow SOLID principles (as then someone fixes a bug in a base class method that shouldn't be shared. This fixes an issue in a subclass but introduces one in another. Rinse, repeat.