Is it better to have code duplication and have it be very simple/readable, or have no duplication (using generics) but be much more complicated?

code-duplication, generics, java

Solution

I always favor the solution with no duplication of code. Even if the more complicated architecture is harder to understand at first, the benefits to maintenance more than outweigh the learning curve.

Problem

In general I come across this a lot. Some of my co-workers prefer very simple, easy to read classes even if that means that there is some code duplication, whereas I do everything in my power to avoid code duplication, even if it means making more a complicated architecture. What is the best practice? I work exclusively in Java.

Original source