3 ms·
Poor or incomplete abstractions and code duplication. They usually go hand in hand. What typically happens is that one developer needs to solve a problem. He
by alexeiz 8y ago
Poor or incomplete abstractions and code duplication. They usually go hand in hand. What typically happens is that one developer needs to solve a problem. He creates some abstraction (one or more classes) to help him solve the problem. He tries to make his abstraction reusable, but it's hard to do if there is only one use case for it. So the abstraction ends up with some essential functionality missing. Or worse, the abstraction may be poorly designed, so it's not reusable at all.
The second developer comes along with his own problem to solve. He looks around and finds that abstraction that solves a similar problem. He tries to use it, and it doesn't quite work for him. He could fix the abstraction, but that would require changing code where it's used. He doesn't want to touch someone else's code because he just wants to solve his problem. Or perhaps he just didn't realize how to use it correctly (because it wasn't well designed in the first place). So he goes ahead and creates a copy of the abstraction, modifies it slightly to fit his needs and voila - his problem is solved.
Couple of more iterations like this and you get poorly designed code being copied all over the place with slight variations. If there is a critical flaw discovered in all these copies, it becomes a major pain to fix. So naturally nobody wants to touch such code with a ten foot pole. In the mean time, the bad code gets duplicated more and more like cancer.