DEV Community

Discussion on: Flexible code considered harmful

Collapse
the3rdc profile image
Cody Crumrine

I think it's interesting to combine "flexible" and "abstraction" here. When I was new to OOP I thought that was the point of Abstraction - to be very flexible, usable for lots of scenarios. And that's kind of right... But I took it to mean I should write classes that could do a lot of different things (depending on what you needed).

Actually, abstraction should be about writing classes (or modules, prototypes, whatever) that can do 1 specific thing really well. The flexibility comes from the fact that you can take them to do that one thing in almost any context - they don't care.

I think rather than warning to avoid abstraction, we need to teach that abstraction is about separation of concerns, not about flexibility.